The setTimeout()
and setInterval()
methods allow authors to schedule timer-based callbacks.
[Supplemental, NoInterfaceObject] interface WindowTimers { long setTimeout(in any handler, in optional any timeout, in any... args); void clearTimeout(in long handle); long setInterval(in any handler, in optional any timeout, in any... args); void clearInterval(in long handle); }; Window implements WindowTimers;
setTimeout
( handler [, timeout [, arguments ] ] )Schedules a timeout to run handler after timeout milliseconds. Any arguments are passed straight through to the handler.
setTimeout
( code [, timeout ] )Schedules a timeout to compile and run code after timeout milliseconds.
clearTimeout
( handle )Cancels the timeout set with setTimeout()
identified by handle.
setInterval
( handler [, timeout [, arguments ] ] )Schedules a timeout to run handler every timeout milliseconds. Any arguments are passed straight through to the handler.
setInterval
( code [, timeout ] )Schedules a timeout to compile and run code every timeout milliseconds.
clearInterval
( handle )Cancels the timeout set with setInterval()
identified by handle.
This API does not guarantee that timers will fire exactly on schedule. Delays due to CPU load, other tasks, etc, are to be expected.
alert
(message)Displays a modal alert with the given message, and waits for the user to dismiss it.
A call to the navigator.yieldForStorageUpdates()
method is implied when this method is invoked.
confirm
(message)Displays a modal OK/Cancel prompt with the given message, waits for the user to dismiss it, and returns true if the user clicks OK and false if the user clicks Cancel.
A call to the navigator.yieldForStorageUpdates()
method is implied when this method is invoked.
prompt
(message [, default] )Displays a modal text field prompt with the given message, waits for the user to dismiss it, and returns the value that the user entered. If the user cancels the prompt, then returns null instead. If the second argument is present, then the given value is used as a default.
A call to the navigator.yieldForStorageUpdates()
method is implied when this method is invoked.
print
()Prompts the user to print the page.
A call to the navigator.yieldForStorageUpdates()
method is implied when this method is invoked.
showModalDialog
(url [, argument] )Prompts the user with the given page, waits for that page to close, and returns the return value.
A call to the navigator.yieldForStorageUpdates()
method is implied when this method is invoked.
[NoInterfaceObject] interface WindowModal { readonly attribute any dialogArguments; attribute DOMString returnValue; };
dialogArguments
Returns the argument argument that was
passed to the showModalDialog()
method.
returnValue
[ = value ]Returns the current return value for the window.
Can be set, to change the value that will be returned by the
showModalDialog()
method.
The window.close()
method can be used to
close the browsing context.
Navigator
objectinterface Navigator { // objects implementing this interface also implement the interfaces given below }; Navigator implements NavigatorID; Navigator implements NavigatorOnLine; Navigator implements NavigatorContentUtils; Navigator implements NavigatorStorageUtils;
[Supplemental, NoInterfaceObject] interface NavigatorID { readonly attribute DOMString appName; readonly attribute DOMString appVersion; readonly attribute DOMString platform; readonly attribute DOMString userAgent; };
In certain cases, despite the best efforts of the entire industry, Web browsers have bugs and limitations that Web authors are forced to work around.
This section defines a collection of attributes that can be used to determine, from script, the kind of user agent in use, in order to work around these issues.
Client detection should always be limited to detecting known current versions; future versions and unknown versions should always be assumed to be fully compliant.
navigator
. appName
Returns the name of the browser.
navigator
. appVersion
Returns the version of the browser.
navigator
. platform
Returns the name of the platform.
navigator
. userAgent
Returns the complete User-Agent header.
[Supplemental, NoInterfaceObject] interface NavigatorContentUtils { // content handler registration void registerProtocolHandler(in DOMString scheme, in DOMString url, in DOMString title); void registerContentHandler(in DOMString mimeType, in DOMString url, in DOMString title); };
The registerProtocolHandler()
method allows Web sites to register themselves as possible handlers
for particular schemes. For example, an online telephone messaging
service could register itself as a handler of the sms:
scheme ([RFC5724]), so that if the user
clicks on such a link, he is given the opportunity to use that Web
site. Analogously, the registerContentHandler()
method allows Web sites to register themselves as possible handlers
for content in a particular MIME type. For example, the
same online telephone messaging service could register itself as a
handler for text/directory
files ([RFC2425]), so that if the user has no
native application capable of handling vCards ([RFC2426]), his Web browser can instead
suggest he use that site to view contact information stored on
vCards that he opens.
navigator
. registerProtocolHandler
(scheme, url, title)navigator
. registerContentHandler
(mimeType, url, title)Registers a handler for the given scheme or content type, at the given URL, with the given title.
The string "%s
" in the URL is used as a
placeholder for where to put the URL of the content to be
handled.
Throws a SECURITY_ERR
exception if the user agent
blocks the registration (this might happen if trying to register
as a handler for "http", for instance).
Throws a SYNTAX_ERR
if the "%s
" string is missing in the URL.
[Supplemental, NoInterfaceObject] interface NavigatorStorageUtils { void yieldForStorageUpdates(); };
navigator
. yieldForStorageUpdates
()If a script uses the document.cookie
API, or the
localStorage
API, the
browser will block other scripts from accessing cookies or storage
until the first script finishes.
[WEBSTORAGE]
Calling the navigator.yieldForStorageUpdates()
method tells the user agent to unblock any other scripts that may
be blocked, even though the script hasn't returned.
Values of cookies and items in the Storage
objects
of localStorage
attributes
can change after calling this method, whence its name.
[WEBSTORAGE]