HTML java c#
appla · 2008-03-21(近似)
2008年01月18日
APIs for creating and navigating browsing contexts by name
- [
]
Tag:
The
open()
method on
Window
objects provides a mechanism for
navigating
an existing
browsing context
or opening and navigating an
auxiliary browsing context
.
The method has four arguments, though they are all optional.
The first argument, url, gives a URI (or IRI) for a page to load in the browsing context. If no arguments are provided, then the url argument defaults to "
about:blank
". The argument must be resolved to an absolute URI by
...
The second argument, target, specifies the
name
of the browsing context that is to be navigated. It must be a
valid browsing context name
. If fewer than two arguments are provided, then the name argument defaults to the value "
_blank
".
The third argument, features, has no effect and is supported for historical reasons only.
The fourth argument, replace, specifies whether or not the new page will
replace
the page currently loaded in the browsing context, when target identifies an existing browsing context (as opposed to leaving the current page in the browsing context's
session history
). When three or fewer arguments are provided, replace defaults to false.
When the method is invoked, the user agent must first select a
browsing context
to navigate by applying
the rules for chosing a browsing context given a browsing context name
using the target argument as the name and the
browsing context
of the script as the context in which the algorithm is executed, unless the user has indicated a preference, in which case the browsing context to navigate may instead be the one indicated by the user.
For example, suppose there is a user agent that supports control-clicking a link to open it in a new tab. If a user clicks in that user agent on an element whose
onclick
handler uses the
window.open()
API to open a page in an iframe, but, while doing so, holds the control key down, the user agent could override the selection of the target browsing context to instead target a new tab.
Then, the user agent must
navigate
the selected
browsing context
to the URI given in url. If the replace is true, then
replacement must be enabled
; otherwise, it must not be enabled unless the
browsing context
was just created as part of the
the rules for chosing a browsing context given a browsing context name
.
The method must return the
Window
object of the default view of the
browsing context
that was navigated, or null if no browsing context was navigated.
The
name
attribute of the
Window
object must, on getting, return the current name of the
browsing context
, and, on setting, set the name of the
browsing context
to the new value.
The name
gets reset
when the browsing context is navigated to another domain.
4.2.4.
Accessing other browsing contexts
In ECMAScript implementations, objects that implement the
Window
interface must have a [[Get]] method that, when invoked with a property name that is a number i, returns the ith
child browsing context
of the
active
Document
, sorted in document order of the elements nesting those browsing contexts.
The
length
DOM attribute on the
Window
interface must return the number of
child browsing contexts
of the
active
Document
.
4.3.
Scripting
4.3.1.
Running executable code
Various mechanisms can cause author-provided executable code to run in the context of a document. These mechanisms include, but are probably not limited to:
Processing of
script
elements.
Processing of inline
javascript:
URIs (e.g. the
src
attribute of
img
elements, or an
@import
rule in a CSS
style
element block).
Event handlers, whether registered through the DOM using
addEventListener()
, by explicit
event handler content attributes
, by
event handler DOM attributes
, or otherwise.
Processing of technologies like XBL or SVG that have their own scripting features.
User agents may provide a mechanism to enable or disable the execution of author-provided code. When the user agent is configured such that author-provided code does not execute, or if the user agent is implemented so as to never execute author-provided code, it is said that scripting is disabled. When author-provided code
does
execute, scripting is enabled. A user agent with scripting disabled is a
user agent with no scripting support
for the purposes of conformance.
4.3.2.
Origin
Access to certain APIs is granted or denied to scripts based on the origin of the script and the API being accessed.
The origin of a script depends on the context of that script:
If a script is in a
script
element
The origin of the script is the origin of the
Document
to which the
script
element belongs.
If a script is a function or other code reference created by another script
The origin of the script is the origin of the script that created it.
If a script is a
javascript:
URI
in an attribute
The origin is the origin of the
Document
of the element on which the attribute is found.
If a script is a
javascript:
URI
in a style sheet
The origin is the origin of the
Document
to which the style sheet applies.
If a script is a
javascript:
URI
to which a
browsing context
is being
navigated
, the URI having been provided by the user (e.g. by using a
bookmarklet
)
The origin is the origin of the
Document
of the
browsing context
's
active document
.
If a script is a
javascript:
URI
to which a
browsing context
is being
navigated
, the URI having been declared in markup
The origin is the origin of the
Document
of the element (e.g. an
a
or
area
element) that declared the URI.
If a script is a
javascript:
URI
to which a
browsing context
is being
navigated
, the URI having been provided by script
The origin is the origin of the script that provided the URI.
The origin of scripts thus comes down to finding the origin of
Document
objects.
The origin of a
Document
or image that was served over the network and whose address uses a URI scheme with a server-based naming authority is the tuple consisting of the <scheme>, <host>/<ihost>, and <port> parts of the
Document
's full URI.
[RFC3986]
[RFC3987]
The origin of a
Document
or image that was generated from a
data:
URI found in another
Document
or in a script is the origin of the
Document
or script.
The origin of a
Document
or image that was generated from a
data:
URI from another source is a globally unique identifier assigned when the document is created.
The origin of a
Document
or image that was generated from a
javascript:
URI
is the same as the origin of that
javascript:
URI.
The string representing the script's domain in IDNA format is obtained as follows: take the domain part of the script's
origin
tuple and apply the IDNA ToASCII algorithm and then the IDNA ToUnicode algorithm to each component of the domain name (with both the AllowUnassigned and UseSTD3ASCIIRules flags set both times).
[RFC3490]
If ToASCII fails to convert one of the components of the string, e.g. because it is too long or because it contains invalid characters, or if the origin of the script has no domain part, then the string representing the script's domain in IDNA format cannot be obtained. (ToUnicode is defined to never fail.)
It's been suggested that we should put IP addresses into the origin tuple, to mitigate DNS rebinding attacks. However that would kill multi-homed systems like GMail. Should we do something like have a DNS record say whether or not to include the IP in the origin for a host?
4.3.3.
Unscripted same-origin checks
When two URIs are to be compared to determine if they have the same scheme/host/port, it means that the following algorithm must be invoked, where uri
1
and uri
2
are the two URIs.
First, both uri
1
and uri
2
must be normalized to obtain the two tuples (scheme
1
, host
1
, port
1
) and (scheme
2
, host
2
, port
2
), by applying the following subalgorithm to each URI:
Let uri be the URI being normalized.
Parse uri according to the rules described in RFC 3986 and RFC 3987.
[RFC3986]
[RFC3987]
If uri does not use a server-based naming authority, then fail the overall algorithm — the two URIs do not have the same scheme/host/port.
Let scheme be the <scheme> component of the URI. If the UA doesn't support the given protocol, then fail the overall algorithm — the two URIs do not have the same scheme/host/port
.
Let host be the <host>/<ihost> component of the URI.
Apply the IDNA ToASCII algorithm to host, with both the AllowUnassigned and UseSTD3ASCIIRules flags set. Let host be the result of the ToASCII algorithm.
If ToASCII fails to convert one of the components of the string, e.g. because it is too long or because it contains invalid characters, then fail the overall algorithm — the two URIs do not have the same scheme/host/port.
[RFC3490]
If no port is explicitly listed, then let port be the default port for the protocol given by scheme. Otherwise, let port be the <port> component of the URI.
Return the tuple (scheme, host, port).
If scheme
1
is not case-insensitively
identical to scheme
2
, or if host
1
is not case-insensitively
identical to host
2
, or if port
1
is not identical to port
2
, then fail the overall algorithm — the two URIs do not have the same scheme/host/port.
Otherwise, the two URIs do have the same scheme/host/port
luguangjun
发表于22:06:20 |
引用(0)
|
编辑
原始快照:web.archive.org