public interface Document extends Node, NodeSelector
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:
document
in document's scripts. (The same document can also be referred to as window.document
.)contentDocument
property.responseXML
of an XMLHttpRequest
object.ownerDocument
property.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:
Document
and Node
interfaces, meaning that the "core" properties and methods are available for all kinds of documents.HTMLDocument
interface, which is a more specialized interface for dealing with HTML documents (e.g., document.cookie, document.alinkColor).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:
Detailed browser compatibility tables are located at the pages describing each property or method.
Modifier and Type | Interface and Description |
---|---|
static interface |
Document.Events
Contains the set of standard values used with
createEvent(java.lang.String) . |
static interface |
Document.ReadyState
Contains the set of standard values returned by
#readyState . |
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
addEventListener, addEventListener, appendChild, cloneNode, compareDocumentPosition, contains, dispatchEvent, getAttributes, getBaseURI, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPrefix, getPreviousSibling, getTextContent, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, removeEventListener, removeEventListener, replaceChild, setNodeValue, setPrefix, setTextContent
String getURL()
Element getActiveElement()
String getAlinkColor()
void setAlinkColor(String arg)
HTMLAllCollection getAll()
void setAll(HTMLAllCollection arg)
HTMLCollection getAnchors()
HTMLCollection getApplets()
String getBgColor()
void setBgColor(String arg)
Element getBody()
void setBody(Element arg)
String getCharacterSet()
String getCharset()
void setCharset(String arg)
String getCompatMode()
String getCookie()
void setCookie(String arg)
String getDefaultCharset()
Window getDefaultView()
String getDesignMode()
void setDesignMode(String arg)
String getDir()
void setDir(String arg)
DocumentType getDoctype()
Element getDocumentElement()
String getDocumentURI()
void setDocumentURI(String arg)
String getDomain()
void setDomain(String arg)
HTMLCollection getEmbeds()
String getFgColor()
void setFgColor(String arg)
HTMLCollection getForms()
HeadElement getHead()
int getHeight()
HTMLCollection getImages()
DOMImplementation getImplementation()
String getInputEncoding()
String getLastModified()
String getLinkColor()
void setLinkColor(String arg)
HTMLCollection getLinks()
Location getLocation()
void setLocation(Location arg)
EventListener getOnabort()
void setOnabort(EventListener arg)
EventListener getOnbeforecopy()
void setOnbeforecopy(EventListener arg)
EventListener getOnbeforecut()
void setOnbeforecut(EventListener arg)
EventListener getOnbeforepaste()
void setOnbeforepaste(EventListener arg)
EventListener getOnblur()
void setOnblur(EventListener arg)
EventListener getOnchange()
void setOnchange(EventListener arg)
EventListener getOnclick()
void setOnclick(EventListener arg)
EventListener getOncontextmenu()
void setOncontextmenu(EventListener arg)
EventListener getOncopy()
void setOncopy(EventListener arg)
EventListener getOncut()
void setOncut(EventListener arg)
EventListener getOndblclick()
void setOndblclick(EventListener arg)
EventListener getOndrag()
void setOndrag(EventListener arg)
EventListener getOndragend()
void setOndragend(EventListener arg)
EventListener getOndragenter()
void setOndragenter(EventListener arg)
EventListener getOndragleave()
void setOndragleave(EventListener arg)
EventListener getOndragover()
void setOndragover(EventListener arg)
EventListener getOndragstart()
void setOndragstart(EventListener arg)
EventListener getOndrop()
void setOndrop(EventListener arg)
EventListener getOnerror()
void setOnerror(EventListener arg)
EventListener getOnfocus()
void setOnfocus(EventListener arg)
EventListener getOninput()
void setOninput(EventListener arg)
EventListener getOninvalid()
void setOninvalid(EventListener arg)
EventListener getOnkeydown()
void setOnkeydown(EventListener arg)
EventListener getOnkeypress()
void setOnkeypress(EventListener arg)
EventListener getOnkeyup()
void setOnkeyup(EventListener arg)
EventListener getOnload()
void setOnload(EventListener arg)
EventListener getOnmousedown()
void setOnmousedown(EventListener arg)
EventListener getOnmousemove()
void setOnmousemove(EventListener arg)
EventListener getOnmouseout()
void setOnmouseout(EventListener arg)
EventListener getOnmouseover()
void setOnmouseover(EventListener arg)
EventListener getOnmouseup()
void setOnmouseup(EventListener arg)
EventListener getOnmousewheel()
void setOnmousewheel(EventListener arg)
EventListener getOnpaste()
void setOnpaste(EventListener arg)
EventListener getOnreadystatechange()
readystatechange
event.
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.
void setOnreadystatechange(EventListener arg)
EventListener getOnreset()
void setOnreset(EventListener arg)
EventListener getOnscroll()
void setOnscroll(EventListener arg)
EventListener getOnsearch()
void setOnsearch(EventListener arg)
EventListener getOnselect()
void setOnselect(EventListener arg)
EventListener getOnselectionchange()
void setOnselectionchange(EventListener arg)
EventListener getOnselectstart()
void setOnselectstart(EventListener arg)
EventListener getOnsubmit()
void setOnsubmit(EventListener arg)
EventListener getOntouchcancel()
void setOntouchcancel(EventListener arg)
EventListener getOntouchend()
void setOntouchend(EventListener arg)
EventListener getOntouchmove()
void setOntouchmove(EventListener arg)
EventListener getOntouchstart()
void setOntouchstart(EventListener arg)
EventListener getOnwebkitfullscreenchange()
void setOnwebkitfullscreenchange(EventListener arg)
EventListener getOnwebkitfullscreenerror()
void setOnwebkitfullscreenerror(EventListener arg)
HTMLCollection getPlugins()
String getPreferredStylesheetSet()
String getReadyState()
String getReferrer()
HTMLCollection getScripts()
<script>
elements on the document.String getSelectedStylesheetSet()
void setSelectedStylesheetSet(String arg)
StyleSheetList getStyleSheets()
String getTitle()
void setTitle(String arg)
String getVlinkColor()
void setVlinkColor(String arg)
Element getWebkitCurrentFullScreenElement()
boolean isWebkitFullScreenKeyboardInputAllowed()
Element getWebkitFullscreenElement()
boolean isWebkitFullscreenEnabled()
boolean isWebkitHidden()
boolean isWebkitIsFullScreen()
String getWebkitVisibilityState()
int getWidth()
String getXmlEncoding()
boolean isXmlStandalone()
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
.void setXmlStandalone(boolean arg)
String getXmlVersion()
"1.0"
if the declaration is absent.void setXmlVersion(String arg)
Node adoptNode(Node source)
Node.appendChild
Range caretRangeFromPoint(int x, int y)
Attr createAttributeNS(String namespaceURI, String qualifiedName)
CDATASection createCDATASection(String data)
DocumentFragment createDocumentFragment()
Element createElementNS(String namespaceURI, String qualifiedName)
EntityReference createEntityReference(String name)
XPathExpression createExpression(String expression, XPathNSResolver resolver)
XPathExpression
which can then be used for (repeated) evaluations.XPathNSResolver createNSResolver(Node nodeResolver)
NodeIterator createNodeIterator(Node root, int whatToShow, NodeFilter filter, boolean expandEntityReferences)
ProcessingInstruction createProcessingInstruction(String target, String data)
Range createRange()
Touch createTouch(Window window, EventTarget target, int identifier, int pageX, int pageY, int screenX, int screenY, int webkitRadiusX, int webkitRadiusY, float webkitRotationAngle, float webkitForce)
TouchList createTouchList()
TreeWalker createTreeWalker(Node root, int whatToShow, NodeFilter filter, boolean expandEntityReferences)
treeWalker
object.Element elementFromPoint(int x, int y)
XPathResult evaluate(String expression, Node contextNode, XPathNSResolver resolver, int type, XPathResult inResult)
boolean execCommand(String command, boolean userInterface, String value)
CanvasRenderingContext getCSSCanvasContext(String contextId, String name, int width, int height)
Element getElementById(String elementId)
NodeList getElementsByClassName(String tagname)
NodeList getElementsByName(String elementName)
NodeList getElementsByTagName(String tagname)
NodeList getElementsByTagNameNS(String namespaceURI, String localName)
Node.getFeature
CSSStyleDeclaration getOverrideStyle(Element element, String pseudoElement)
Selection getSelection()
Selection
object related to text selected in the document.Node.getUserData
Node.hasAttributes
Node.hasChildNodes
Node importNode(Node importedNode)
Node.insertBefore
Node.isDefaultNamespace
Node.isEqualNode
Node.isSameNode
Node.isSupported
Node importNode(Node importedNode, boolean deep)
Node.insertBefore
Node.isDefaultNamespace
Node.isEqualNode
Node.isSameNode
Node.isSupported
boolean queryCommandEnabled(String command)
boolean queryCommandIndeterm(String command)
boolean queryCommandState(String command)
boolean queryCommandSupported(String command)
String queryCommandValue(String command)
Element querySelector(String selectors)
querySelector
in interface NodeSelector
NodeList querySelectorAll(String selectors)
querySelectorAll
in interface NodeSelector
void webkitCancelFullScreen()
void webkitExitFullscreen()
void captureEvents()
void clear()
Node.cloneNode
void close()
Node.compareDocumentPosition
boolean hasFocus()
true
if the focus is currently located anywhere inside the specified document.void open()
void releaseEvents()
Node.removeChild
void write(String text)
void writeln(String text)
AnchorElement createAnchorElement()
AppletElement createAppletElement()
AreaElement createAreaElement()
AudioElement createAudioElement()
BRElement createBRElement()
BaseElement createBaseElement()
BaseFontElement createBaseFontElement()
BodyElement createBodyElement()
ButtonElement createButtonElement()
CanvasElement createCanvasElement()
ContentElement createContentElement()
DListElement createDListElement()
DetailsElement createDetailsElement()
DirectoryElement createDirectoryElement()
DivElement createDivElement()
EmbedElement createEmbedElement()
FieldSetElement createFieldSetElement()
FontElement createFontElement()
FormElement createFormElement()
FrameElement createFrameElement()
FrameSetElement createFrameSetElement()
HRElement createHRElement()
HeadElement createHeadElement()
HeadingElement createHeadingElement()
HtmlElement createHtmlElement()
IFrameElement createIFrameElement()
ImageElement createImageElement()
InputElement createInputElement()
KeygenElement createKeygenElement()
LIElement createLIElement()
LabelElement createLabelElement()
LegendElement createLegendElement()
LinkElement createLinkElement()
MapElement createMapElement()
MarqueeElement createMarqueeElement()
MediaElement createMediaElement()
MenuElement createMenuElement()
MetaElement createMetaElement()
MeterElement createMeterElement()
ModElement createModElement()
OListElement createOListElement()
ObjectElement createObjectElement()
OptGroupElement createOptGroupElement()
OptionElement createOptionElement()
OutputElement createOutputElement()
ParagraphElement createParagraphElement()
ParamElement createParamElement()
PreElement createPreElement()
ProgressElement createProgressElement()
QuoteElement createQuoteElement()
SVGAElement createSVGAElement()
SVGAltGlyphDefElement createSVGAltGlyphDefElement()
SVGAltGlyphElement createSVGAltGlyphElement()
SVGAltGlyphItemElement createSVGAltGlyphItemElement()
SVGAnimateColorElement createSVGAnimateColorElement()
SVGAnimateElement createSVGAnimateElement()
SVGAnimateMotionElement createSVGAnimateMotionElement()
SVGAnimateTransformElement createSVGAnimateTransformElement()
SVGAnimationElement createSVGAnimationElement()
SVGCircleElement createSVGCircleElement()
SVGClipPathElement createSVGClipPathElement()
SVGComponentTransferFunctionElement createSVGComponentTransferFunctionElement()
SVGCursorElement createSVGCursorElement()
SVGDefsElement createSVGDefsElement()
SVGDescElement createSVGDescElement()
SVGEllipseElement createSVGEllipseElement()
SVGFEBlendElement createSVGFEBlendElement()
SVGFEColorMatrixElement createSVGFEColorMatrixElement()
SVGFEComponentTransferElement createSVGFEComponentTransferElement()
SVGFECompositeElement createSVGFECompositeElement()
SVGFEConvolveMatrixElement createSVGFEConvolveMatrixElement()
SVGFEDiffuseLightingElement createSVGFEDiffuseLightingElement()
SVGFEDisplacementMapElement createSVGFEDisplacementMapElement()
SVGFEDistantLightElement createSVGFEDistantLightElement()
SVGFEDropShadowElement createSVGFEDropShadowElement()
SVGFEFloodElement createSVGFEFloodElement()
SVGFEFuncAElement createSVGFEFuncAElement()
SVGFEFuncBElement createSVGFEFuncBElement()
SVGFEFuncGElement createSVGFEFuncGElement()
SVGFEFuncRElement createSVGFEFuncRElement()
SVGFEGaussianBlurElement createSVGFEGaussianBlurElement()
SVGFEImageElement createSVGFEImageElement()
SVGFEMergeElement createSVGFEMergeElement()
SVGFEMergeNodeElement createSVGFEMergeNodeElement()
SVGFEMorphologyElement createSVGFEMorphologyElement()
SVGFEOffsetElement createSVGFEOffsetElement()
SVGFEPointLightElement createSVGFEPointLightElement()
SVGFESpecularLightingElement createSVGFESpecularLightingElement()
SVGFESpotLightElement createSVGFESpotLightElement()
SVGFETileElement createSVGFETileElement()
SVGFETurbulenceElement createSVGFETurbulenceElement()
SVGFilterElement createSVGFilterElement()
SVGFontElement createSVGFontElement()
SVGFontFaceElement createSVGFontFaceElement()
SVGFontFaceFormatElement createSVGFontFaceFormatElement()
SVGFontFaceNameElement createSVGFontFaceNameElement()
SVGFontFaceSrcElement createSVGFontFaceSrcElement()
SVGFontFaceUriElement createSVGFontFaceUriElement()
SVGForeignObjectElement createSVGForeignObjectElement()
SVGGElement createSVGGElement()
SVGGlyphElement createSVGGlyphElement()
SVGGlyphRefElement createSVGGlyphRefElement()
SVGGradientElement createSVGGradientElement()
SVGHKernElement createSVGHKernElement()
SVGImageElement createSVGImageElement()
SVGLineElement createSVGLineElement()
SVGLinearGradientElement createSVGLinearGradientElement()
SVGMPathElement createSVGMPathElement()
SVGMarkerElement createSVGMarkerElement()
SVGMaskElement createSVGMaskElement()
SVGMetadataElement createSVGMetadataElement()
SVGMissingGlyphElement createSVGMissingGlyphElement()
SVGPathElement createSVGPathElement()
SVGPatternElement createSVGPatternElement()
SVGPolygonElement createSVGPolygonElement()
SVGPolylineElement createSVGPolylineElement()
SVGRadialGradientElement createSVGRadialGradientElement()
SVGRectElement createSVGRectElement()
SVGSVGElement createSVGElement()
SVGScriptElement createSVGScriptElement()
SVGSetElement createSVGSetElement()
SVGStopElement createSVGStopElement()
SVGStyleElement createSVGStyleElement()
SVGSwitchElement createSVGSwitchElement()
SVGSymbolElement createSVGSymbolElement()
SVGTRefElement createSVGTRefElement()
SVGTSpanElement createSVGTSpanElement()
SVGTextContentElement createSVGTextContentElement()
SVGTextElement createSVGTextElement()
SVGTextPathElement createSVGTextPathElement()
SVGTextPositioningElement createSVGTextPositioningElement()
SVGTitleElement createSVGTitleElement()
SVGUseElement createSVGUseElement()
SVGVKernElement createSVGVKernElement()
SVGViewElement createSVGViewElement()
ScriptElement createScriptElement()
SelectElement createSelectElement()
ShadowElement createShadowElement()
SourceElement createSourceElement()
SpanElement createSpanElement()
StyleElement createStyleElement()
TableCaptionElement createTableCaptionElement()
TableCellElement createTableCellElement()
TableColElement createTableColElement()
TableElement createTableElement()
TableRowElement createTableRowElement()
TableSectionElement createTableSectionElement()
TextAreaElement createTextAreaElement()
TitleElement createTitleElement()
TrackElement createTrackElement()
UListElement createUListElement()
UnknownElement createUnknownElement()
VideoElement createVideoElement()
Copyright © 2016. All rights reserved.