Document

extern class js.html.Documentextends NodeAvailable in js

Each web page loaded in the browser has its own document object. This object serves as an entry point to the web page's content (the DOM tree, including elements such as <body> and <table> ) and provides functionality global to the document (such as obtaining the page's URL and creating new elements in the document).

A document object can be obtained from various APIs:

Depending on the kind of the document (e.g. HTML or XML) different APIs may be available on the document object. This theoretical availability of APIs is usually described in terms of implementing interfaces defined in the relevant W3C DOM specifications:

  • All document objects implement the DOM Core Document and Node interfaces, meaning that the "core" properties and methods are available for all kinds of documents.
  • In addition to the generalized DOM Core document interface, HTML documents also implement the HTMLDocument interface, which is a more specialized interface for dealing with HTML documents (e.g., document.cookie, document.alinkColor).
  • XUL documents (available to Mozilla add-on and application developers) implement their own additions to the core Document functionality.

Methods or properties listed here that are part of a more specialized interface have an asterisk (*) next to them and have additional information in the  Availability column.

Note that some APIs listed below are not available in all browsers for various reasons:

  • Obsolete: on its way of being removed from supporting browsers.
  • Non-standard: either an experimental feature not (yet?) agreed upon by all vendors, or a feature targeted specifically at the code running in a specific browser (e.g. Mozilla has a few DOM APIs created for its add-ons and application development).
  • Part of a completed or an emerging standard, but not (yet?) implemented in all browsers or implemented in the newest versions of the browsers.

Detailed browser compatibility tables are located at the pages describing each property or method.



Documentation for this class was provided by MDN.
var URL(default,null) : StringReturns a string containing the URL of the current document. var activeElement(default,null) : ElementReturns the currently focused element var alinkColor : StringReturns or sets the color of active links in the document body. var all : HTMLAllCollection var anchors(default,null) : HTMLCollectionReturns a list of all of the anchors in the document. var applets(default,null) : HTMLCollectionReturns an ordered list of the applets within a document. var bgColor : StringGets/sets the background color of the current document. var body : ElementReturns the BODY node of the current document. Setter throws DOMException. var characterSet(default,null) : StringReturns the character set being used by the document. var charset : String var compatMode(default,null) : StringIndicates whether the document is rendered in Quirks or Strict mode. var cookie : StringReturns a semicolon-separated list of the cookies for that document or sets a single cookie. Getter throws DOMException. Setter throws DOMException. var currentFullScreenElement(default,null) : Element var defaultCharset(default,null) : String var defaultView(default,null) : DOMWindowReturns a reference to the window object. var designMode : StringGets/sets WYSYWIG editing capability of Midas. It can only be used for HTML documents. var dir : StringGets/sets directionality (rtl/ltr) of the document var doctype(default,null) : DocumentTypeReturns the Document Type Definition (DTD) of the current document. var documentElement(default,null) : ElementReturns the Element that is a direct child of document. For HTML documents, this is normally the HTML element. var documentURI(default,null) : StringReturns the document location. var domain : StringReturns the domain of the current document. Setter throws DOMException. var embeds(default,null) : HTMLCollectionReturns a list of the embedded OBJECTS within the current document. var fgColor : StringGets/sets the foreground color, or text color, of the current document. var forms(default,null) : HTMLCollectionReturns a list of the FORM elements within the current document. var fullScreenKeyboardInputAllowed(default,null) : Bool var fullscreenElement(default,null) : Element var fullscreenEnabled(default,null) : Bool var head(default,null) : HeadElementReturns the HEAD node of the current document. var height(default,null) : IntGets/sets the height of the current document. var hidden(default,null) : Bool var images(default,null) : HTMLCollectionReturns a list of the images in the current document. var implementation(default,null) : DOMImplementationReturns the DOM implementation associated with the current document. var inputEncoding(default,null) : StringReturns the encoding used when the document was parsed. var isFullScreen(default,null) : Bool var lastModified(default,null) : StringReturns the date on which the document was last modified. var linkColor : StringGets/sets the color of hyperlinks in the document. var links(default,null) : HTMLCollectionReturns a list of all the hyperlinks in the document. var location : LocationReturns the URI of the current document. var onabort : EventListener var onbeforecopy : EventListener var onbeforecut : EventListener var onbeforepaste : EventListener var onblur : EventListener var onchange : EventListener var onclick : EventListener var oncontextmenu : EventListener var oncopy : EventListener var oncut : EventListener var ondblclick : EventListener var ondrag : EventListener var ondragend : EventListener var ondragenter : EventListener var ondragleave : EventListener var ondragover : EventListener var ondragstart : EventListener var ondrop : EventListener var onerror : EventListener var onfocus : EventListener var onfullscreenchange : EventListener var onfullscreenerror : EventListener var oninput : EventListener var oninvalid : EventListener var onkeydown : EventListener var onkeypress : EventListener var onkeyup : EventListener var onload : EventListener var onmousedown : EventListener var onmousemove : EventListener var onmouseout : EventListener var onmouseover : EventListener var onmouseup : EventListener var onmousewheel : EventListener var onpaste : EventListener var onpointerlockchange : EventListener var onpointerlockerror : EventListener var onreadystatechange : EventListener
Returns the event handling code for the readystatechange event.

Gecko 9.0 note
(Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6)

Starting in Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6) , you can now use the syntax if ("onabort" in document) to determine whether or not a given event handler property exists. This is because event handler interfaces have been updated to be proper web IDL interfaces. See DOM event handlers for details.

var onreset : EventListener var onscroll : EventListener var onsearch : EventListener var onselect : EventListener var onselectionchange : EventListener var onselectstart : EventListener var onsubmit : EventListener var ontouchcancel : EventListener var ontouchend : EventListener var ontouchmove : EventListener var ontouchstart : EventListener var plugins(default,null) : HTMLCollectionReturns a list of the available plugins. var pointerLockElement(default,null) : Element var preferredStylesheetSet(default,null) : String var readyState(default,null) : StringReturns loading status of the document var referrer(default,null) : StringReturns the URI of the page that linked to this page. var scripts(default,null) : HTMLCollectionReturns all the <script> elements on the document. var selectedStylesheetSet : String var styleSheets(default,null) : StyleSheetListReturns a list of the stylesheet objects on the current document. var title : StringReturns the title of the current document. var visibilityState(default,null) : String var vlinkColor : StringGets/sets the color of visited hyperlinks. var width(default,null) : IntReturns the width of the current document. var xmlEncoding(default,null) : StringReturns the encoding as determined by the XML declaration.
Firefox 10 and later don't implement it anymore.
var xmlStandalone : BoolReturns true if the XML declaration specifies the document is standalone (e.g., An external part of the DTD affects the document's content), else false. Setter throws DOMException. var xmlVersion : StringReturns the version number as specified in the XML declaration or "1.0" if the declaration is absent. Setter throws DOMException. function adoptNode( source : Node ) : Node function cancelFullScreen() : Void function captureEvents() : Void function caretRangeFromPoint( x : Int, y : Int ) : Range function clear() : Void function close() : Void inline function createAnchorElement() : AnchorElementA typed shortcut for createElement("a"). inline function createAppletElement() : AppletElementA typed shortcut for createElement("applet"). inline function createAreaElement() : AreaElementA typed shortcut for createElement("area"). function createAttribute( name : String ) : Attr function createAttributeNS( ?namespaceURI : String, ?qualifiedName : String ) : Attr inline function createAudioElement() : AudioElementA typed shortcut for createElement("audio"). inline function createBRElement() : BRElementA typed shortcut for createElement("br"). inline function createBaseElement() : BaseElementA typed shortcut for createElement("base"). inline function createBaseFontElement() : BaseFontElementA typed shortcut for createElement("basefont"). inline function createBodyElement() : BodyElementA typed shortcut for createElement("body"). inline function createButtonElement() : ButtonElementA typed shortcut for createElement("button"). function createCDATASection( data : String ) : CDATASection inline function createCanvasElement() : CanvasElementA typed shortcut for createElement("canvas"). function createComment( data : String ) : Comment inline function createContentElement() : ContentElementA typed shortcut for createElement("content"). inline function createDListElement() : DListElementA typed shortcut for createElement("dl"). inline function createDataListElement() : DataListElementA typed shortcut for createElement("datalist"). inline function createDetailsElement() : DetailsElementA typed shortcut for createElement("details"). inline function createDirectoryElement() : DirectoryElementA typed shortcut for createElement("dir"). inline function createDivElement() : DivElementA typed shortcut for createElement("div"). function createDocumentFragment() : DocumentFragment function createElement( ?tagName : String ) : Element function createElementNS( ?namespaceURI : String, ?qualifiedName : String ) : Element inline function createEmbedElement() : EmbedElementA typed shortcut for createElement("embed"). function createEntityReference( name : String ) : EntityReference function createEvent( eventType : String ) : Event function createExpression( expression : String, resolver : XPathNSResolver ) : XPathExpression inline function createFieldSetElement() : FieldSetElementA typed shortcut for createElement("fieldset"). inline function createFontElement() : FontElementA typed shortcut for createElement("font"). inline function createFormElement() : FormElementA typed shortcut for createElement("form"). inline function createFrameElement() : FrameElementA typed shortcut for createElement("frame"). inline function createFrameSetElement() : FrameSetElementA typed shortcut for createElement("frameset"). inline function createHRElement() : HRElementA typed shortcut for createElement("hr"). inline function createHeadElement() : HeadElementA typed shortcut for createElement("head"). inline function createHtmlElement() : HtmlElementA typed shortcut for createElement("html"). inline function createIFrameElement() : IFrameElementA typed shortcut for createElement("iframe"). inline function createImageElement() : ImageElementA typed shortcut for createElement("img"). inline function createInputElement() : InputElementA typed shortcut for createElement("input"). inline function createKeygenElement() : KeygenElementA typed shortcut for createElement("keygen"). inline function createLIElement() : LIElementA typed shortcut for createElement("li"). inline function createLabelElement() : LabelElementA typed shortcut for createElement("label"). inline function createLegendElement() : LegendElementA typed shortcut for createElement("legend"). inline function createLinkElement() : LinkElementA typed shortcut for createElement("link"). inline function createMapElement() : MapElementA typed shortcut for createElement("map"). inline function createMarqueeElement() : MarqueeElementA typed shortcut for createElement("marquee"). inline function createMediaElement() : MediaElementA typed shortcut for createElement("media"). inline function createMenuElement() : MenuElementA typed shortcut for createElement("menu"). inline function createMetaElement() : MetaElementA typed shortcut for createElement("meta"). inline function createMeterElement() : MeterElementA typed shortcut for createElement("meter"). inline function createModElement() : ModElementA typed shortcut for createElement("mod"). function createNSResolver( nodeResolver : Node ) : XPathNSResolver function createNodeIterator( root : Node, whatToShow : Int, filter : NodeFilter, expandEntityReferences : Bool ) : NodeIterator inline function createOListElement() : OListElementA typed shortcut for createElement("ol"). inline function createObjectElement() : ObjectElementA typed shortcut for createElement("object"). inline function createOptGroupElement() : OptGroupElementA typed shortcut for createElement("optgroup"). inline function createOptionElement() : OptionElementA typed shortcut for createElement("option"). inline function createOutputElement() : OutputElementA typed shortcut for createElement("output"). inline function createParagraphElement() : ParagraphElementA typed shortcut for createElement("p"). inline function createParamElement() : ParamElementA typed shortcut for createElement("param"). inline function createPreElement() : PreElementA typed shortcut for createElement("pre"). function createProcessingInstruction( target : String, data : String ) : ProcessingInstruction inline function createProgressElement() : ProgressElementA typed shortcut for createElement("progress"). inline function createQuoteElement() : QuoteElementA typed shortcut for createElement("quote"). function createRange() : Range inline function createScriptElement() : ScriptElementA typed shortcut for createElement("script"). inline function createSelectElement() : SelectElementA typed shortcut for createElement("select"). inline function createShadowElement() : ShadowElementA typed shortcut for createElement("shadow"). inline function createSourceElement() : SourceElementA typed shortcut for createElement("source"). inline function createSpanElement() : SpanElementA typed shortcut for createElement("span"). inline function createStyleElement() : StyleElementA typed shortcut for createElement("style"). inline function createTableCaptionElement() : TableCaptionElementA typed shortcut for createElement("caption"). inline function createTableCellElement() : TableCellElementA typed shortcut for createElement("td"). inline function createTableColElement() : TableColElementA typed shortcut for createElement("col"). inline function createTableElement() : TableElementA typed shortcut for createElement("table"). inline function createTableRowElement() : TableRowElementA typed shortcut for createElement("tr"). inline function createTableSectionElement() : TableSectionElementA typed shortcut for createElement("thead"). inline function createTextAreaElement() : TextAreaElementA typed shortcut for createElement("textarea"). function createTextNode( data : String ) : Text inline function createTitleElement() : TitleElementA typed shortcut for createElement("title"). function createTouch( window : DOMWindow, target : EventTarget, identifier : Int, pageX : Int, pageY : Int, screenX : Int, screenY : Int, radiusX : Int, radiusY : Int, rotationAngle : Float, force : Float ) : Touch function createTouchList() : TouchList inline function createTrackElement() : TrackElementA typed shortcut for createElement("track"). function createTreeWalker( root : Node, whatToShow : Int, filter : NodeFilter, expandEntityReferences : Bool ) : TreeWalker inline function createUListElement() : UListElementA typed shortcut for createElement("ul"). inline function createVideoElement() : VideoElementA typed shortcut for createElement("video"). function elementFromPoint( x : Int, y : Int ) : Element function evaluate( expression : String, contextNode : Node, resolver : XPathNSResolver, type : Int, inResult : XPathResult ) : XPathResult function execCommand( command : String, userInterface : Bool, ?value : String ) : Bool function exitFullscreen() : Void function exitPointerLock() : Void function getCSSCanvasContext( contextId : String, name : String, width : Int, height : Int ) : CanvasRenderingContext function getElementById( elementId : String ) : Element function getElementsByClassName( tagname : String ) : NodeList function getElementsByName( elementName : String ) : NodeList function getElementsByTagName( tagname : String ) : NodeList function getElementsByTagNameNS( ?namespaceURI : String, localName : String ) : NodeList function getOverrideStyle( element : Element, pseudoElement : String ) : CSSStyleDeclaration function getSelection() : DOMSelection function hasFocus() : Bool function importNode( importedNode : Node, ?deep : Bool ) : Node function open() : Void function queryCommandEnabled( command : String ) : Bool function queryCommandIndeterm( command : String ) : Bool function queryCommandState( command : String ) : Bool function queryCommandSupported( command : String ) : Bool function queryCommandValue( command : String ) : String function querySelector( selectors : String ) : Element function querySelectorAll( selectors : String ) : NodeList function releaseEvents() : Void function write( text : String ) : Void function writeln( text : String ) : Void
version #19197, modified 2013-05-08 11:06:39 by api
0 comment