From 7e0af8a03d4432f4f226718cdcab3e0434453d80 Mon Sep 17 00:00:00 2001
From: Anne van Kesteren
var a = document.links[0]; // obtain the first link in the document -a.href = 'sample.html'; // change the destination URL of the link -a.protocol = 'https'; // change just the scheme part of the URL +a.href = 'sample.html'; // change the destination URL of the link +a.protocol = 'https'; // change just the scheme part of the URL a.setAttribute('href', 'http://example.com/'); // change the content attribute directly
Since DOM trees are used as the way to represent HTML documents when they are processed and @@ -2729,16 +2729,6 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
URLUtils
interface
- URLUtilsReadOnly
interface
- href
IDL attribute
- protocol
IDL attribute
- URLUtils
- URLUtils
- URLUtils
- URLUtils
object
- URLUtils
object
- URLUtils
object
A number of schemes and protocols are referenced by this specification also:
@@ -8202,7 +8192,7 @@ interface DOMStringMap { [OverrideBuiltins] partial /*sealed*/ interface Document { // resource metadata management - [PutForwards=href, Unforgeable] readonly attribute Location? location; + [PutForwards=href, Unforgeable] readonly attribute Location? location; attribute DOMString domain; readonly attribute DOMString referrer; attribute DOMString cookie; @@ -78998,7 +78988,7 @@ dictionary DragEventInit : MouseEventInit { [Replaceable] readonly attribute WindowProxy self; [Unforgeable] readonly attribute Document document; attribute DOMString name; - [PutForwards=href, Unforgeable] readonly attribute Location location; + [PutForwards=href, Unforgeable] readonly attribute Location location; readonly attribute History history; [Replaceable] readonly attribute BarProp locationbar; [Replaceable] readonly attribute BarProp menubar; @@ -81396,58 +81386,433 @@ State: <OUTPUT NAME=I>1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O data-x="dom-history">history object.[Unforgeable] interface Location { - void assign(DOMString url); - void replace(DOMString url); + stringifier attribute USVString href; + attribute USVString origin; + attribute USVString protocol; + attribute USVString host; + attribute USVString hostname; + attribute USVString port; + attribute USVString pathname; + attribute USVString search; + attribute USVString hash; + + void assign(USVString url); + void replace(USVString url); void reload(); - [SameObject] readonly attribute DOMString[] ancestorOrigins; -}; -Location implements URLUtils;+ [SameObject] readonly attribute USVString[] ancestorOrigins; +};
toString()
href
Returns the Location
object's URL.
Can be set, to navigate to the given URL.
+assign
(url)origin
Returns the Location
object's URL's origin.
protocol
Returns the Location
object's URL's scheme.
Can be set, to navigate to the same URL with a changed scheme.
+host
Returns the Location
object's URL's host and port (if different from the default
+ port for the scheme).
Can be set, to navigate to the same URL with a changed host and port.
+Navigates to the given page.
+hostname
Returns the Location
object's URL's host.
Can be set, to navigate to the same URL with a changed host.
+port
Returns the Location
object's URL's port.
Can be set, to navigate to the same URL with a changed port.
replace
(url)pathname
Returns the Location
object's URL's path.
Can be set, to navigate to the same URL with a changed path.
+search
Returns the Location
object's URL's query (includes leading "?
" if non-empty).
Can be set, to navigate to the same URL with a changed query (ignores leading "?
").
hash
Returns the Location
object's URL's fragment (includes leading "#
" if non-empty).
Can be set, to navigate to the same URL with a changed fragment (ignores leading "#
").
Removes the current page from the session history and navigates to the given page.
+assign
(url)Navigates to the given URL.
+replace
(url)Removes the current page from the session history and navigates to the given URL.
reload
()Reloads the current page.
-ancestorOrigins
Returns an array values are the origins of the ancestor browsing contexts, from the parent browsing context to the top-level browsing context.
-The relevant Document
is the Location
object's associated
+
A Location
object has an associated relevant
+ Document
, which is this Location
object's associated
Document
object's browsing context's active document.
A Location
object has an associated url, which is this Location
object's
+ relevant Document
's address.
A Location
object has an associated Location
-object-setter
+ navigate algorithm, which given a url, runs these steps:
If any of the following conditions are met, let replacement flag be unset; + otherwise, let it be set:
+ +Location
object's relevant Document
has
+ completely loaded, orclick
event was trusted, orclick
event is being handled.Location
-object navigate, given url and
+ replacement flag.
To Location
-object navigate, given a url and
+ replacement flag, run these steps:
The source browsing context is the responsible browsing context + specified by the incumbent settings object.
Navigate the browsing context to + url, with exceptions enabled.
+ +If the replacement flag is set or the browsing context's
+ session history contains only one Document
, and that was the
+ about:blank
Document
created when the browsing context
+ was created, then the navigation must be done with replacement enabled.
The href
attribute's getter must return this
+ Location
object's url, serialised.
The href
attribute's setter must run these steps:
Let newURL be the resulting parsed URL of resolving the given value relative to the entry settings object's + API base URL.
If that aborted with an error, throw a TypeError
exception.
Location
-object-setter navigate to newURL.
The origin
attribute's getter return the
+ Unicode serialization of this
+ Location
object's url's origin.
It returns the Unicode rather than the ASCII serialisation for
+ compatibility with MessageEvent
.
The protocol
attribute's getter must
+ return this Location
object's url's scheme, followed by ":
".
The protocol
attribute's setter must run these
+ steps:
Let copyURL be a copy of this Location
object's url.
Let possibleFailure be the result of basic URL
+ parsing the given value, followed by ":
", with copyURL
+ as url and scheme start state as state override.
If possibleFailure is failure, throw a TypeError
+ exception.
If copyURL's scheme is not "http
" or "https
", terminate these steps.
Location
-object-setter navigate to copyURL.
The host
attribute's getter must run these
+ steps:
Let url be this Location
object's url.
If url's host is null, return the empty + string.
If url's port is null, return + url's host, serialised.
Return url's host, serialised, followed by ":
" and url's port, serialised.
The host
attribute's setter must run these steps:
Let copyURL be a copy of this Location
object's url.
If copyURL's non-relative flag is set, terminate these + steps.
Basic URL parse the given value, with + copyURL as url and host state as state + override.
Location
-object-setter navigate to copyURL.
The hostname
attribute's getter must
+ run these steps:
If this Location
object's url's
+ host is null, return the empty string.
Return this Location
object's url's host, serialised.
The hostname
attribute's setter must run these
+ steps:
Let copyURL be a copy of this Location
object's url.
If copyURL's non-relative flag is set, terminate these + steps.
Basic URL parse the given value, with + copyURL as url and hostname state as state + override.
Location
-object-setter navigate to copyURL.
The port
attribute's getter must run these
+ steps:
If this Location
object's url's
+ port is null, return the empty string.
Return this Location
object's url's port, serialised.
The port
attribute's setter must run these steps:
Let copyURL be a copy of this Location
object's url.
If copyURL's host is null,
+ copyURL's non-relative flag is set, or copyURL's scheme is "file
", terminate these
+ steps.
Basic URL parse the given value, with + copyURL as url and port state as state + override.
Location
-object-setter navigate to copyURL.
The pathname
attribute's getter must
+ run these steps:
Let url be this Location
object's url.
If url's non-relative flag is set, return the first string in + url's path.
Return "/
", followed by the strings in url's path (including empty strings), separated from each other by
+ "/
".
The pathname
attribute's setter must run these
+ steps:
Let copyURL be a copy of this Location
object's url.
If copyURL's non-relative flag is set, terminate these + steps.
Set copyURL's path to the empty + list.
Basic URL parse the given value, with + copyURL as url and path start state as state + override.
Location
-object-setter navigate to copyURL.
The search
attribute's getter must run
+ these steps:
If this Location
object's url's
+ query is either null or the empty string, return the
+ empty string.
Return "?
", followed by this Location
object's url's query.
The search
attribute's setter must run these
+ steps:
Let copyURL be a copy of this Location
object's url.
If the given value is the empty string, set copyURL's query to null. + +
Otherwise, run these substeps:
+ +Let input be the given value with a single leading "?
"
+ removed, if any.
Set copyURL's query to the empty + string.
Basic URL parse input, with
+ copyURL as url and query state as state override,
+ and the relevant Document
's document's character
+ encoding as encoding override.
Location
-object-setter navigate to copyURL.
The hash
attribute's getter must run these
+ steps:
If this Location
object's url's
+ fragment is either null or the empty string, return
+ the empty string.
Return "#
", followed by this Location
object's url's fragment.
The hash
attribute's setter must run these steps:
Let copyURL be a copy of this Location
object's url.
If copyURL's scheme is "javascript
", terminate these steps.
If the given value is the empty string, set copyURL's fragment to null. + +
Otherwise, run these substeps:
+ +Let input be the given value with a single leading "#
"
+ removed, if any.
Set copyURL's fragment to the + empty string.
Basic URL parse input, with + copyURL as url and fragment state as state + override.
Location
-object-setter navigate to copyURL.
When the assign(url)
method is invoked, the user agent must run the following steps:
@@ -81464,20 +81829,7 @@ State: <OUTPUT NAME=I>1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O
-
Navigate the browsing context to - parsedURL, with exceptions enabled.
- -If the browsing context's session history contains only one
- Document
, and that was the about:blank
Document
created
- when the browsing context was created, then the navigation must be done with
- replacement enabled.
Location
-object navigate to parsedURL.
Navigate the - browsing context to parsedURL, with replacement enabled - and exceptions enabled.
Location
-object navigate to parsedURL with the
+ replacement flag set.
Navigation for the assign()
and replace()
methods must be done with the responsible
- browsing context specified by the incumbent settings object as the
- source browsing context.
When the reload()
method is invoked, the
user agent must run the appropriate steps from the following list:
The Location
interface also supports the URLUtils
interface.
When the object is created, and whenever the the
- address of the relevant Document
changes, the user agent must invoke
- the object's URLUtils
interface's set the
- input algorithm with the address of the
- relevant Document
as the given value.
The object's URLUtils
interface's get the
- base algorithm must return the API base URL specified by the entry
- settings object, if there is one, or null otherwise.
The object's URLUtils
interface's query
- encoding is the document's character encoding.
When the object's URLUtils
interface invokes its update steps with the string value, the
- user agent must run the following steps:
If any of the following conditions are met, let mode be normal - navigation; otherwise, let it be replace navigation:
- -Location
object's relevant Document
has
- completely loaded, orclick
event was trusted, orclick
event is being handled.If mode is normal navigation, then act as if the assign()
method had been called with value as its
- argument. Otherwise, act as if the replace()
method
- had been called with value as its argument.
The ancestorOrigins
attribute, on
getting, must return a read only array whose values are
determined as follows. The same object must be returned each time the attribute's value is
@@ -81673,7 +81959,7 @@ State: <OUTPUT NAME=I>1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O
href
setter, if the responsible browsing
+ href
setter, if the responsible browsing
context specified by the entry settings object is familiar with
the browsing context with which the Location
object is associated