Proxy Traps And Reflect Methods deleteProperty()
The deleteProperty() trap is called inside the delete operator. Its corresponding Reflect API method is Reflect.deleteProperty().Example
const myTarget = {}; const proxy = new Proxy(myTarget, { deleteProperty(target, property) { console.log('deleteProperty()'); return Reflect.deleteProperty(...arguments) } }); delete proxy.foo Output:Return value
deleteProperty() must return a Boolean indicating if the property was successfully deleted or not. Non-Boolean return values will be coerced into a Boolean.Intercepted operations
delete proxy.property delete proxy[property] Reflect.deleteProperty(proxy, property)Trap handler parameters
target - Target object property - String key property being referenced on target objectTrap invariants
If an own target.property exists and is non-configurable, the handler cannot delete the property.Proxy Traps And Reflect Methods ownKeys()
The ownKeys() trap is called inside Object.keys() and similar methods. Its corresponding Reflect API method is Reflect.ownKeys().Example
const myTarget = {}; const proxy = new Proxy(myTarget, { ownKeys(target) { console.log('ownKeys()'); return Reflect.ownKeys(...arguments) } }); Object.keys(proxy); Output:Return value
ownKeys() must return an enumerable object that contains either strings or symbols.Intercepted operations
Object.getOwnPropertyNames(proxy) Object.getOwnPropertySymbols(proxy) Object.keys(proxy) Reflect.ownKeys(proxy)Trap handler parameters
Setting | Value(S) | Description |
---|---|---|
height | Number | The initial height of the new window. This cannot be less than 100. |
left | Number | The initial left coordinate of the new window. This cannot be a negative number. |
location | "yes" or "no" | Indicates if the location bar should be displayed. The default varies based on the browser. When set to "no", the location bar may be either hidden or disabled. |
menubar | "yes" or "no" | Indicates if the menu bar should be displayed. The default is "no". |
resizable | "yes" or "no" | Indicates if the new window can be resized by dragging its border. The default is "no". |
scrollbars | "yes" or "no" | Indicates if the new window allows scrolling if the content cannot fit in the viewport. The default is "no". |
status | "yes" or "no" | Indicates if the status bar should be displayed. The default varies based on the browser. |
toolbar | "yes" or "no" | Indicates if the toolbar should be displayed. The default is "no". |
top | Number | The initial top coordinate of the new window. This cannot be a negative number. |
width | Number | The initial width of the new window. This cannot be less than 100. |
Name | Description | Returns |
---|---|---|
clearInterval(<id>) | Cancels an interval timer | void |
clearTimeout(<id>) | Cancels a timeout timer | void |
setInterval(<function>, <time>) | Creates a timer that will call the specified function every time milliseconds | int |
setTimeout(<function>, <time>) | Creates a timer that will call the specified function once after time milliseconds | int |
Name | Description | Returns |
---|---|---|
alert(<msg>) | Displays a dialog window to the user and waits for it to be dismissed | void |
confirm(<msg>) | Displays a dialog window with an OK/Cancel prompt | boolean |
prompt(<msg>, <val>) | Displays a dialog prompting the user to enter a value | string |
showModalDialog(<url>) | Displays a popup window showing the specified URL | void |
Property | Description | Returns |
---|---|---|
protocol | Gets or sets the protocol component of the document URL | string |
host | Gets or sets the host component of the document URL | string |
href | Gets or sets the current document's location | string |
hostname | Gets or sets the host name component of the document URL | string |
port | Gets or sets the port component of the document URL | string |
pathname | Gets or sets the path component of the document URL | string |
search | Gets or sets the query component of the document URL | string |
hash | Gets or sets the hash component of the document URL | string |
assign(<URL>) | Navigates to the specified URL | void |
replace(<URL>) | Removes the current document and navigates to the one specified by the URL. | void |
reload() | Reloads the current document | void |
resolveURL(<URL>) | Resolves the specified relative URL to an absolute one | string |
Property Name | Return Value | Description |
---|---|---|
location.hash | "#contents" | The URL hash, or an empty string if the URL does not have a hash. |
location.host | "www.demo2s.com:80" | The name of the server and port number if present. |
location.hostname | "www.demo2s.com" | The name of the server without the port number. |
location.href | "http://www.demo2s. com:80/html-folder/?q= javascript#contents" | The full URL of the currently loaded page. The toString() method of location returns this value. |
location.pathname | "/html-folder/" | The directory and/or filename of the URL. |
location.port | "80" | The port of the request if specified in the URL. If a URL does not contain a port, then this property returns an empty string. |
location.protocol | "http:" | The protocol used by the page. Typically "http:" or "https:". |
location.search | "?q=javascript" | The query string of the URL. It returns a string beginning with a question mark. |
location.username | "userName" | The username specified before the domain name. |
location.password | "usrPas" | The password specified before the domain name. |
location.origin | "http:// www.demo2s.com" | The origin of the URL. Read only. |
Property/Method | Description |
---|---|
activeVrDisplays | Returns an array of every VRDisplay instance with its ispresenting property set to true. |
appCodeName | Returns "Mozilla" even in non-Mozilla browsers. |
appName | Full browser name. |
appVersion | Browser version. Typically does not correspond to the actual browser version. |
battery | Returns a BatteryManager object to interact with the Battery Status API. |
buildId | Build number for the browser. |
connection | Returns a NetworkInformation object to interact with the Network Information API. |
cookieEnabled | Indicates if cookies are enabled. |
credentials | A CredentialsContainer to interact with the Credentials Management API. |
deviceMemory | The amount of device memory in gigabytes. |
doNotTrack | The user's do-not-track preference. |
geolocation | A Geolocation object to interact with the Geolocation API. |
getVRDisplays() | Returns an array of every VRDisplay instance available. |
getUserMedia() | Returns the stream associated with the available media device hardware. |
hardwareConcurrency | The device's number of processor cores. |
javaEnabled | Indicates if Java is enabled in the browser. |
language | The browser's primary language. |
languages | An array of all the browser's preferred languages. |
locks | A LockManager object to interact with the Web Locks API. |
mediaCapabilities | A MediaCapabilities object to interact with the Media Capabilities API. |
mediaDevices | The available media devices. |
maxTouchPoints | The maximum number of supported touch points for the device's touch screen. |
mimeTypes | Array of MIME types registered with the browser. |
onLine | Indicates if the browser is connected to the Internet. |
oscpu | The operating system and/or CPU on which the browser is running. |
permissions | A Permissions object to interact with the Permissions API. |
platform | The system platform on which the browser is running. |
plugins | Array of plug-ins installed on the browser. |
product | The name of the product, typically Gecko. |
productSub | Extra information about the product (typically Gecko version information). |
registerProtocolHandler() | Registers a website as a handler for a particular protocol. |
requestMediaKeySystemAccess() | Returns a Promise which resolves to a MediaKeySystemAccess object. |
sendBeacon() | Asynchronously transmits a small payload. |
serviceWorker | The ServiceWorkerContainer used to interact with ServiceWorker objects. |
share() | If available, invokes the current platform's native sharing mechanism. |
storage | Returns the StorageManager object to interact with the Storage API. |
userAgent | The user-agent string for the browser. |
vendor | The brand name of the browser. |
vendorSub | Extra information about the vendor. |
vibrate() | Triggers the device to vibrate if vibration is supported. |
webdriver | Indicates if the browser is controlled by automation. |
Property | Description |
---|---|
availHeight | The pixel height of the screen minus system elements such as Windows (read only). |
availLeft | The first pixel from the left that is not taken up by system elements (read only). |
availTop | The first pixel from the top that is not taken up by system elements (read only). |
availWidth | The pixel width of the screen minus system elements (read only). |
colorDepth | The number of bits used to represent colors; for most systems, 32 (read only). |
height | The pixel height of the screen. |
left | The pixel distance of the current screen's left side. |
pixelDepth | The bit depth of the screen (read only). |
top | The pixel distance of the current screen's top. |
width | The pixel width of the screen. |
orientation | Returns the screen orientation as specified in the Screen Orientation API. |
Name | Description | Returns |
---|---|---|
back() | Goes one step back in the history | void |
forward() | Goes one step forward in the history | void |
go(<index>) | Goes to a position in the history relative to the current document; positive values are forward, and negative values are backward | void |
length | Returns the number of items in the history | number |
pushState(<state>, <title>, <url>) | Adds an entry to the browser history | void |
replaceState(<state>, <title>, <url>) | Replaces the current entry in the browser history | void |
state | Returns the state data associated with the current document in the browser history | object |
Method | Description |
---|---|
assign() | Location assign new value Method |
reload() | Location reload url Method |
replace() | Location replace url Method |
Property | Description |
---|---|
hash | Location Get and Set url hash Property |
host | Location Get and Set host Property |
hostname | Location Get and Set host name Property |
href | Location Get and Set href URL Property |
origin | Location Get and Set URL origin Property |
pathname | Location Get and Set URL path name Property |
port | Location Get and Set URL port Property |
protocol | Location Get and Set URL protocol Property |
search | Location Get and Set URL search part Property |
Property | Description |
---|---|
length | History length Property |
Method | Description |
---|---|
back() | History go back Method |
forward() | History go forward Method |
go() | History go to a history step Method |
Property | Description |
---|---|
appCodeName | Javascript Navigator Get appCodeName Property |
appName | Javascript Navigator Get appName Property |
appVersion | Javascript Navigator Get appVersion Property |
cookieEnabled | Javascript Navigator Get cookieEnabled Property |
geolocation | Javascript Navigator Get geolocation Property |
language | Javascript Navigator Get language Property |
Navigator check if browser is on Line | Javascript Navigator check if browser is on Line |
platform | Javascript Navigator Get platform Property |
product | Javascript Navigator Get product Property |
userAgent | Javascript Navigator Get userAgent Property |
javaEnabled() | Javascript Navigator Check if java is Enabled Method |
taintEnabled() | Javascript Navigator is taint Enabled Method |
availHeight
| Yes | Yes | Yes | Yes | Yes | Yes |
Property | Description |
---|---|
available Width | Screen Get available Width Property |
color Depth | Screen Get color Depth Property |
height | Screen Get height Property |
pixel Depth | Screen Get pixel Depth Property |
width | Screen Get width Property |
Method | Description |
---|---|
alert() | displays an alert box with a specified message and an OK button |
atob() | decodes a base-64 encoded string |
blur() | removes focus from the current window |
btoa() | encodes a string in base-64 |
clearInterval() | clears a timer set with the setInterval method |
clearTimeout() | clears a timer set with the setTimeout method |
close() | closes the current window |
confirm() | displays a dialog box with a specified message |
focus() | sets focus to the current window |
matchMedia() | match media query |
moveBy() | moves a window relative to its current coordinates |
moveTo() | moves a window's left and top edge to the specified coordinates |
open() | opens a new browser window |
print() | prints the contents of the current window |
prompt() | displays a dialog box that prompts the user for input |
resizeBy() | resizes a window by the specified amount |
resizeTo() | resizes a window to the specified width and height |
scrollBy() | scrolls the document by the specified number of pixels |
scrollTo() | scrolls the document to the specified coordinates |
setInterval() | calls a function at specified intervals in milliseconds |
setTimeout() | calls a function after a specified number of milliseconds |
stop() | stops window loading |
Property | Description |
---|---|
closed | checks whether a window is closed |
defaultStatus | Get and Set default Status text |
frameElement | returns the <iframe> element where current window is inserted |
frames | get all iframe elements |
innerWidth and innerHeight | innerWidth and innerHeight get client size |
length | get the number of iframe elements |
localStorage | Get local Storage Property |
name | Get and Set name Property |
opener | Get the window that created current window |
outerWidth and outerHeight | Get size |
pageXOffset and pageYOffset | Get the scrolled offset |
parent | get the parent window of the current window. |
screenLeft and screenTop | Get coordinates of the window relative to the screen |
screenX and screenY | Get coordinates of the window relative to the screen. |
self | returns the current window |
sessionStorage | Get session Storage Property |
status | Get and Set status text |
top | Get the topmost browser window of the current window |
Item | Meaning |
---|---|
caption | Pointer to the <caption> element (if it exists). |
tBodies | An HTMLCollection of <tbody> elements. |
tFoot | Pointer to the <tfoot> element (if it exists). |
tHead | Pointer to the <thead> element (if it exists). |
rows | An HTMLCollection of all rows in the table. |
createTHead() | Creates a <thead> element, places it into the table, and returns a reference. |
createTFoot() | Creates a <tfoot> element, places it into the table, and returns a reference. |
createCaption() | Creates a <caption> element, places it into the table, and returns a reference. |
deleteTHead() | Deletes the <thead> element. |
deleteTFoot() | Deletes the <tfoot> element. |
deleteCaption() | Deletes the <caption> element. |
deleteRow(pos) | Deletes the row in the given position. |
insertRow(pos) | Inserts a row in the given position in the rows collection. |
Item | Meaning |
---|---|
rows | An HTMLCollection of rows in the <tbody> element. |
deleteRow(pos) | Deletes the row in the given position. |
insertRow(pos) | Inserts a row in the given position in the rows collection and returns a reference to the new row. |
Item | Meaning |
---|---|
cells | An HTMLCollection of cells in the <tr> element. |
deleteCell(pos) | Deletes the cell in the given position. |
insertCell(pos) | Inserts a cell in the given position in the cells collection and returns a reference to the new cell. |
Key | Value |
---|---|
target | The node that was affected by the mutation. |
type | A string indicating what type of mutation occurred. Can be "attributes", "characterData", or "childList". |
oldValue | When enabled in the MutationObserverInit object, attributes or characterData mutations will set this field to the value that was replaced. This value is only provided when attributeOldValue or characterDataOldValue is true, otherwise this value is null. A childList mutation will always set this field to null. |
attributeName | For attributes mutations, the string name of the attribute which was modified. For all other mutations, this field is set to null. |
attributeNamespace | For attributes mutations which make use of namespaces, the string namespace of the attribute which was modified. For all other mutations, this field is set to null. |
addedNodes | For childList mutations, returns a NodeList of nodes added in the mutation. Defaults to an empty NodeList. |
removedNodes | For childList mutations, returns a NodeList of nodes removed in the mutation. Defaults to an empty NodeList. |
previousSibling | For childList mutations, returns the previous sibling Node of the mutated node. Defaults to null. |
nextSibling | For childList mutations, returns the next sibling Node of the mutated node. Defaults to null. |
Key | Type | Value |
---|---|---|
subtree | Boolean | Indicating if the target element's node subtree should be watched in addition to the target element. When false, only the target element will be observed for designated mutations. When true, the target element and its entire node subtree will be watched for designated mutations. Defaults to false. |
attributes | Boolean | Indicating if modifications to node attributes should register as a mutation. Defaults to false. |
attributeFilter | Array of string values | Indicating which specific attributes should be observed for mutations. Setting this value to true will also coerce the value of attributes to true. Defaults to observing all attributes. |
attributeOldValue | Boolean | Indicating if the character data prior to mutation should be recorded in the MutationRecord. Setting this value to an array will also coerce the value of attributes to true. Defaults to false. |
characterData | Boolean | Indicating if modifications to character data should register as a mutation. Defaults to false. |
characterDataOldValue | Boolean | Indicating if the character data prior to mutation should be recorded in the MutationRecord. Setting this value to true will also coerce the value of characterData to true. Defaults to false. |
childList | Boolean | Indicating if modifications to the target node's child nodes should register as a mutation. Defaults to false. |
Css Property | Javascript Property |
---|---|
background-image | style.backgroundImage |
color | style.color |
display | style.display |
font-family | style.fontFamily |
Name cssText | Description provides access to the CSS code of the style attribute. |
---|---|
length | The number of CSS properties applied to the element. |
parentRule | The CSSRule object representing the CSS information. |
getPropertyCSSValue(propertyName) | Returns a CSSValue object containing the value of the given property. |
getPropertyPriority(propertyName) | Returns "important" if the given property is set using !important; otherwise, it returns an empty string. |
getPropertyValue(propertyName) | Returns the string value of the given property. |
item(index) | Returns the name of the CSS property at the given position. |
removeProperty(propertyName) | Removes the given property from the style. |
setProperty(propertyName, value, priority) | Sets the given property to the given value with a priority (either "important" or an empty string). |
Property | Description |
---|---|
disabled | A Boolean value indicating if the style sheet is disabled. This property is read/write, so setting its value to true will disable a style sheet. |
href | The URL of the style sheet if it is included using <link>; otherwise, this is null. |
media | A collection of media types supported by this style sheet. The collection has a length property and item() method, as with all DOM collections. Like other DOM collections, you can use bracket notation to access specific items in the collection. An empty list indicates that the style sheet should be used for all media. |
ownerNode | Pointer to the node that owns the style sheet, which is either a <link> or a <style> element in HTML. This property is null if a style sheet is included in another style sheet using @import. |
parentStyleSheet | When a style sheet is included via @import, this is a pointer to the style sheet that imported it. |
title | The value of the title attribute on the ownerNode. |
type | A string indicating the type of style sheet. For CSS style sheets, this is "text/css". |
Property | Description |
---|---|
cssRules | A collection of rules contained in the style sheet. |
ownerRule | If the style sheet was included using @import, this is a pointer to the rule representing the import; otherwise, this is null. |
deleteRule(index) | Deletes the rule at the given location in the cssRules collection. |
insertRule(rule, index) | Inserts the given string rule at the position specified in the cssRules collection. |
Property | Meaning |
---|---|
cssText | Returns the text for the entire rule. This text may be different from the actual text in the style sheet because of the way that browsers handle style sheets internally; Safari always converts everything to all lowercase. |
parentRule | If this rule is imported, this is the import rule; otherwise, this is null. |
parentStyleSheet | The style sheet that this rule is a part of. |
selectorText | Returns the selector text for the rule. This text may be different from the actual text in the style sheet because of the way that browsers handle style sheets internally. This property is read-only in Firefox, Safari, Chrome, and Internet Explorer (where it throws an error). Opera allows selectorText to be changed. |
style | A CSSStyleDeclaration object that allows the setting and getting of specific style values for the rule. |
type | A constant indicating the type of rule. For style rules, this is always 1. |
Property | Meaning |
---|---|
startContainer | The node within which the range starts. The parent of the first node in the selection. |
startOffset | The offset within the startContainer where the range starts. If startContainer is a text node, comment node, or CData node, the startOffset is the number of characters skipped before the range starts; otherwise, the offset is the index of the first child node in the range. |
endContainer | The node within which the range ends. The parent of the last node in the selection. |
endOffset | The offset within the endContainer where the range ends. It follows the same rules as startOffset. |
commonAncestorContainer | The deepest node in the document that has both startContainer and endContainer as descendants. |
Method | Meaning |
---|---|
setStartBefore(refNode) | Sets the starting point of the range to begin before refNode, so refNode is the first node in the selection. The startContainer property is set to refNode.parentNode, and the startOffset property is set to the index of refNode within its parent's childNodes collection. |
setStartAfter(refNode) | Sets the starting point of the range to begin after refNode, so refNode is not part of the selection; rather, its next sibling is the first node in the selection. The startContainer property is set to refNode.parentNode, and the startOffset property is set to the index of refNode within its parent's childNodes collection plus one. |
setEndBefore(refNode) | Sets the ending point of the range to begin before refNode, so refNode is not part of the selection; its previous sibling is the last node in the selection. The endContainer property is set to refNode.parentNode, and the endOffset property is set to the index of refNode within its parent's childNodes collection. |
setEndAfter(refNode) | Sets the ending point of the range to begin before refNode, so refNode is the last node in the selection. The endContainer property is set to *refNode. parentNode*, and the endOffset property is set to the index of refNode within its parent's childNodes collection plus one. |
Value | Number | Meaning |
---|---|---|
Range.START_TO_START Range.START_TO_END Range.END_TO_END Range.END_TO_START | 0 1 2 3 | Compares the starting point of the first range to the starting point of the second. Compares the starting point of the first range to the end point of the second. Compares the end point of the first range to the end point of the second. Compares the end point of the first range to the starting point of the second. |
Type | Number Value |
---|---|
Node.ELEMENT_NODE | 1 |
Node.ATTRIBUTE_NODE | 2 |
Node.TEXT_NODE | 3 |
Node.CDATA_SECTION_NODE | 4 |
Node.ENTITY_REFERENCE_NODE | 5 |
Node.ENTITY_NODE | 6 |
Node.PROCESSING_INSTRUCTION_NODE | 7 |
Node.COMMENT_NODE | 8 |
Node.DOCUMENT_NODE | 9 |
Node.DOCUMENT_TYPE_NODE | 10 |
Node.DOCUMENT_FRAGMENT_NODE | 11 |
Node.NOTATION_NODE | 12 |
Parameter | Description |
---|---|
root | The node in the tree that you want to start searching from. |
whatToShow | A numerical code indicating which nodes should be visited. |
filter | A NodeFilter object or a function indicating whether a particular node should be accepted or rejected. |
entityReferenceExpansion | A Boolean value indicating whether entity references should be expanded. This has no effect in HTML pages because entity references are never expanded. |
Value | Meaning |
---|---|
NodeFilter.SHOW_ALL | Show all node types. |
NodeFilter.SHOW_ELEMENT | Show element nodes. |
NodeFilter.SHOW_ATTRIBUTE | Show attribute nodes. This can't actually be used because of the DOM structure. |
NodeFilter.SHOW_TEXT | Show text nodes. |
NodeFilter.SHOW_CDATA_SECTION | Show CData section nodes. This is not used in HTML pages. |
NodeFilter.SHOW_ENTITY_REFERENCE | Show entity reference nodes. This is not used in HTML pages. |
NodeFilter.SHOW_ENTITY | Show entity nodes. This is not used in HTML pages. |
NodeFilter.SHOW_PROCESSING_INSTRUCTION | Show PI nodes. This is not used in HTML pages. |
NodeFilter.SHOW_COMMENT | Show comment nodes. |
NodeFilter.SHOW_DOCUMENT | Show document nodes. |
NodeFilter.SHOW_DOCUMENT_TYPE | Show document type nodes. |
NodeFilter.SHOW_DOCUMENT_FRAGMENT | Show document fragment nodes. This is not used in HTML pages. |
NodeFilter.SHOW_NOTATION | Show notation nodes. This is not used in HTML pages. |
Method | Description |
---|---|
parentNode() | Travels to the current node's parent. |
firstChild() | Travels to the first child of the current node. |
lastChild() | Travels to the last child of the current node. |
nextSibling() | Travels to the next sibling of the current node. |
previousSibling() | Travels to the previous sibling of the current node. |
Property | Meaning |
---|---|
localName | The node name without the namespace prefix. |
namespaceURI | The namespace URI of the node or null if not specified. |
prefix | The namespace prefix or null if not specified. |
Method | Meaning |
---|---|
isDefaultNamespace(namespaceURI) | Returns true when the specified namespaceURI is the default namespace for the node. |
lookupNamespaceURI(prefix ) | Returns the namespace URI for the given prefix. |
lookupPrefix(namespaceURI) | Returns the prefix for the given namespaceURI. |
Name | Description | Returns |
---|---|---|
activeElement | Returns an object representing the currently focused element in the document. | HTMLElement |
body | Returns an object representing the body element in the document. | HTMLElement |
characterSet | Returns the document character set encoding. This is a read-only property. | string |
charset | Gets or sets the document character set encoding. | string |
childNodes | Returns the set of child elements. | HTMLElement[] |
compatMode | Gets compatibility mode for the document. | string |
cookie | Gets or sets the cookies for the current document. | string |
defaultCharset | Gets the default character encoding used by the browser. | string |
defaultView | Returns the Window object for the current document. | Window |
dir | Gets or sets the text direction for the document. | string |
domain | Gets or sets the domain for the current document. | string |
embeds | Returns objects representing all the embed elements in the document. | HTMLCollection |
firstChild | Returns the first child element of an element. | HTMLElement |
forms | Returns objects representing all the form elements in the document. | HTMLCollection |
getElementById(<id>) | Returns the element with the specified id value. | HTMLElement |
getElementsByClassName(<class>) | Returns the elements with the specified class value. | HTMLElement[] |
getElementsByName(<name>) | Returns the elements with the specified name value. | HTMLElement[] |
getElementsByTagName(<tag>) | Returns the elements of the specified type. | HTMLElement[] |
hasChildNodes() | Returns true if the current element has child elements. | boolean |
head | Returns an object representing the head element. | HTMLHeadElement |
images | Returns objects representing all the img elements. | HTMLCollection |
implementation | Provides information about the DOM features that are available. | DOMImplementation |
lastChild | Returns the last child element. | HTMLElement |
lastModified | Returns the last modified time of the document. | string |
links | Returns objects representing all the a and area elements in the document that have href attributes. | HTMLCollection |
location | Provides information about the URL of the current document. | Location |
nextSibling | Returns the sibling element defined after the current element. | HTMLElement |
parentNode | Returns the parent element. | HTMLElement |
previousSibling | Returns the sibling element defined before the current element. | HTMLElement |
querySelector(<selector>) | Returns the first element that matches the specified CSS selector. | HTMLElement |
querySelectorAll(<selector>) | Returns all of the elements that match the specified CSS selector. | HTMLElement[] |
readyState | Returns the state of the current document. | string |
referrer | Returns the URL of the document that linked to the current document (this is the value of the corresponding HTTP header). | string |
scripts | Returns objects representing all the script elements. | HTMLCollection |
title | Gets or sets the title of the current document. | string |
Property | Description | Returns |
---|---|---|
characterSet | Returns the document character set encoding. This is a read-only property. | string |
charset | Gets or sets the document character set encoding. | string |
compatMode | Gets the compatibility mode for the document. | string |
cookie | Gets or sets the cookies for the current document. | string |
defaultCharset | Gets the default character encoding used by the browser. | string |
defaultView | Returns the Window object for the current document | Window |
dir | Gets or sets the text direction for the document. | string |
domain | Gets or sets the domain for the current document. | string |
implementation | Provides information about the DOM features that are available. | DOMImplementation |
lastModified | Returns the last modified time of the document (or the current time if no modification time is available). | string |
location | Provides information about the URL of the current document. | Location |
readyState | Returns the state of the current document. This is a read- only property. | string |
referrer | Returns the URL of the document that linked to the current document (this is the value of the corresponding HTTP header). | string |
title | Gets or sets the title of the current document (the contents of the title element, described in Chapter 7). | string |
Addition | Description |
---|---|
path=<path> | Sets the path associated with the cookie; this default to the path of the current document if not specified. |
domain=<domain> | Sets the domain associated with the cookie; this defaults to the domain of the current document if not specified. |
max-age=<seconds> | Sets the life of the cookie in terms of the number of seconds from the moment it was created. |
expires=<date> | Sets the life of the cookie using a GMT-format date. |
secure | The cookie will be sent only over a secure (HTTPS) connection. |
Property | Description | Returns |
---|---|---|
activeElement | Returns an object representing the currently focused element | HTMLElement |
body | Returns an object representing the body element | HTMLElement |
embeds plugins | Returns objects representing all the embed elements | HTMLCollection |
forms | Returns objects representing all the form elements | HTMLCollection |
head | Returns an object representing the head element | HTMLHeadElement |
images | Returns objects representing all the img elements | HTMLCollection |
links | Returns objects representing all the a and area elements in the document that have href attributes | HTMLCollection |
scripts | Returns objects representing all the script elements | HTMLCollection |
Property | Description | Returns |
---|---|---|
getElementById(<id>) | Returns the element with the specified id value | HTMLElement |
getElementsByClassName(<class>) | Returns the elements with the specified class value | HTMLElement[] |
getElementsByName(<name>) | Returns the elements with the specified name value | HTMLElement[] |
getElementsByTagName(<tag>) | Returns the elements of the specified type | HTMLElement[] |
querySelector(<selector>) | Returns the first element that matches the specified CSS selector | HTMLElement |
querySelectorAll(<selector>) | Returns all of the elements that match the specified CSS selector | HTMLElement[] |
Property | Description | Returns |
---|---|---|
childNodes | Returns the set of child elements | HTMLElement[] |
firstChild | Returns the first child element | HTMLElement |
hasChildNodes() | Returns true if the current element has child elements | boolean |
lastChild | Returns the last child element | HTMLElement |
nextSibling | Returns the sibling element defined after the current element | HTMLElement |
parentNode | Returns the parent element | HTMLElement |
previousSibling | Returns the sibling element defined before the current element | HTMLElement |
Name | Description | Returns |
---|---|---|
innerHeight | Gets the height of the window content area | number |
innerWidth | Gets the width of the window content area | number |
outerHeight | Gets the height of the window, including borders, menu bars, and so on | number |
outerWidth | Gets the width of the window, including borders, menu bars, and so on | number |
pageXOffset | Gets the number of pixels that the window has been scrolled horizontally from the top-left corner | number |
pageYOffset | Gets the number of pixels that the window has been scrolled vertically from the top-left corner | number |
screen | Returns a Screen object describing the screen | Screen |
screenLeft screenX | Gets the number of pixels from the left edge of the window to the left edge of the screen | number |
screenTop screenY | Gets the number of pixels from the top edge of the window to the top edge of the screen | number |
Name | Description | Returns |
---|---|---|
availHeight | The height of the portion of the screen available for displaying windows (excludes toolbars, menu bars, and so on) | number |
availWidth | The width of the portion of the screen available for displaying windows (excludes toolbars, menu bars, and so on) | number |
colorDepth | The color depth of the screen | number |
height | The height of the screen | number |
width | The width of the screen | number |
Name | Description | Returns |
---|---|---|
blur() | Un-focuses the window | void |
close() | Closes the window (not all browsers allow a script to close the window) | void |
focus() | Focuses the window | void |
print() | Prompts the user to print the page | void |
scrollBy(<x>, <y>) | Scrolls the document relative to its current position | void |
scrollTo(<x>, <y>) | Scrolls to the specified position | void |
stop() | Stops the document from loading | void |
URL | Result |
---|---|
http://mysub.mydomain.com/apps/other.html | Same origin |
https://mysub.mydomain.com/apps/other.html | Different origin; protocol differs |
https://yourServer::81.mydomain.com/apps/example.html | Different origin; port differs |
http://myserver.mydomain.com/doc.html | Different origin; host differs |
Name | Description | Returns |
---|---|---|
defaultView | Returns the Window for the active document | Window |
frames | Returns an array of the Window objects for the nested iframe elements in the document | Window[] |
opener | Returns the Window that opened the current browsing context | Window |
parent | Returns the parent of the current Window | Window |
self | Returns the Window for the current document | Window |
top | Returns the topmost Window | Window |
length | Returns the number of nested iframe elements in the document | number |
[<index>] | Returns the Window for the nested document at the specified index | Window |
[<name>] | Returns the Window for the nested document with the specified name | Window |
Name | Description | Returns |
---|---|---|
data | Returns the message sent by the other script | object |
origin | Returns the origin of the sending script | string |
source | Returns the window associated with the sending script | Window |