public class HTMLDocument extends Document
HTMLDocument.org.htmlunit.corejs.javascript.ScriptableObject.DescriptorInfo, org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator, org.htmlunit.corejs.javascript.ScriptableObject.LambdaGetterFunction, org.htmlunit.corejs.javascript.ScriptableObject.LambdaSetterFunctionATTRIBUTE_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_NODECONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTNOT_FOUND| Constructor and Description | 
|---|
| HTMLDocument() | 
| Modifier and Type | Method and Description | 
|---|---|
| Node | appendChild(Object childObject)Adds a DOM node to the node. | 
| void | close()JavaScript function  close. | 
| Attr | createAttribute(String attributeName)Creates a new HTML attribute with the specified name. | 
| boolean | dispatchEvent(Event event)Dispatches an event into the event system (standards-conformant browsers only). | 
| HtmlUnitScriptable | elementFromPoint(int x,
                int y)Returns the element for the specified x coordinate and the specified y coordinate. | 
| HTMLElement | getActiveElement()Returns the value of the  activeElementproperty. | 
| String | getBaseURI()Returns the Base URI as a string. | 
| Element | getDocumentElement()Gets the JavaScript property  documentElementfor the document. | 
| DomNode | getDomNodeOrDie()Returns the DOM node that corresponds to this JavaScript object or throw
 an exception if one cannot be found. | 
| HtmlUnitScriptable | getElementById(String id)Returns the element with the specified ID, or  nullif that element could not be found. | 
| HTMLCollection | getElementsByClassName(String className)Returns all the descendant elements with the specified class name. | 
| NodeList | getElementsByName(String elementName)Returns all HTML elements that have a  nameattribute with the specified value. | 
| HTMLElement | getHead()Returns this document's  headelement. | 
| HtmlPage | getPage()Returns the HTML page that this document is modeling. | 
| Selection | getSelection()Returns the current selection. | 
| String | getTitle()Returns this document's title. | 
| protected Object | getWithPreemption(String name)Calls to  document.XYZshould first look at elements namedXYZbefore
 using standard functions. | 
| boolean | hasFocus()Returns  falseif the active element in the document has no focus;trueif the active element in the document has focus. | 
| void | jsConstructor()JavaScript constructor. | 
| HTMLDocument | open(Object url,
    Object name,
    Object features,
    Object replace)JavaScript function "open". | 
| void | setExecutingDynamicExternalPosponed(boolean executing)This a hack!!! | 
| void | setTitle(String title)Sets this document's title. | 
| static void | write(org.htmlunit.corejs.javascript.Context context,
     org.htmlunit.corejs.javascript.Scriptable scope,
     org.htmlunit.corejs.javascript.Scriptable thisObj,
     Object[] args,
     org.htmlunit.corejs.javascript.Function function)JavaScript function "write" may accept a variable number of arguments. | 
| protected void | write(String content)JavaScript function "write". | 
| static void | writeln(org.htmlunit.corejs.javascript.Context context,
       org.htmlunit.corejs.javascript.Scriptable scope,
       org.htmlunit.corejs.javascript.Scriptable thisObj,
       Object[] args,
       org.htmlunit.corejs.javascript.Function function)JavaScript function "writeln" may accept a variable number of arguments. | 
adoptNode, captureEvents, clear, contains, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEvent, createNodeIterator, createNSResolver, createProcessingInstruction, createRange, createTextNode, createTreeWalker, evaluate, execCommand, forceDocumentMode, generateBlobUrl, getAlinkColor, getAll, getAnchors, getApplets, getBgColor, getBody, getCharacterSet, getCharset, getChildElementCount, getChildren, getCompatMode, getContentType, getCookie, getCurrentScript, getDefaultView, getDesignMode, getDoctype, getDocumentMode, getDocumentURI, getDomain, getElementsByTagName, getElementsByTagNameNS, getEmbeds, getFgColor, getFirstElementChild, getFonts, getForms, getImages, getImplementation, getInputEncoding, getLastElementChild, getLastModified, getLinkColor, getLinks, getLocation, getOnabort, getOnafterscriptexecute, getOnauxclick, getOnbeforecopy, getOnbeforecut, getOnbeforepaste, getOnbeforescriptexecute, getOnblur, getOncancel, getOncanplay, getOncanplaythrough, getOnchange, getOnclick, getOnclose, getOncontextmenu, getOncopy, getOncuechange, getOncut, getOndblclick, getOndrag, getOndragend, getOndragenter, getOndragleave, getOndragover, getOndragstart, getOndrop, getOndurationchange, getOnemptied, getOnended, getOnerror, getOnfocus, getOngotpointercapture, getOninput, getOninvalid, getOnkeydown, getOnkeypress, getOnkeyup, getOnload, getOnloadeddata, getOnloadedmetadata, getOnloadstart, getOnlostpointercapture, getOnmousedown, getOnmouseenter, getOnmouseleave, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnmousewheel, getOnmozfullscreenchange, getOnmozfullscreenerror, getOnpaste, getOnpause, getOnplay, getOnplaying, getOnpointercancel, getOnpointerdown, getOnpointerenter, getOnpointerleave, getOnpointerlockchange, getOnpointerlockerror, getOnpointermove, getOnpointerout, getOnpointerover, getOnpointerup, getOnprogress, getOnratechange, getOnreadystatechange, getOnreset, getOnresize, getOnscroll, getOnsearch, getOnseeked, getOnseeking, getOnselect, getOnselectionchange, getOnselectstart, getOnstalled, getOnsubmit, getOnsuspend, getOntimeupdate, getOntoggle, getOnvolumechange, getOnwaiting, getOnwebkitfullscreenchange, getOnwebkitfullscreenerror, getOnwheel, getPlugins, getReadyState, getReferrer, getRootElement, getScripts, getStyleSheets, getURL_js, getVlinkColor, getXmlEncoding, getXmlVersion, importNode, isHidden, isXmlStandalone, queryCommandEnabled, queryCommandSupported, querySelector, querySelectorAll, releaseCapture, releaseEvents, resolveBlobUrl, revokeBlobUrl, setAlinkColor, setBgColor, setBody, setCookie, setCurrentScript, setDesignMode, setDomain, setFgColor, setLinkColor, setLocation, setOnabort, setOnafterscriptexecute, setOnauxclick, setOnbeforecopy, setOnbeforecut, setOnbeforepaste, setOnbeforescriptexecute, setOnblur, setOncancel, setOncanplay, setOncanplaythrough, setOnchange, setOnclick, setOnclose, setOncontextmenu, setOncopy, setOncuechange, setOncut, setOndblclick, setOndrag, setOndragend, setOndragenter, setOndragleave, setOndragover, setOndragstart, setOndrop, setOndurationchange, setOnemptied, setOnended, setOnerror, setOnfocus, setOngotpointercapture, setOninput, setOninvalid, setOnkeydown, setOnkeypress, setOnkeyup, setOnload, setOnloadeddata, setOnloadedmetadata, setOnloadstart, setOnlostpointercapture, setOnmousedown, setOnmouseenter, setOnmouseleave, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnmousewheel, setOnmozfullscreenchange, setOnmozfullscreenerror, setOnpaste, setOnpause, setOnplay, setOnplaying, setOnpointercancel, setOnpointerdown, setOnpointerenter, setOnpointerleave, setOnpointerlockchange, setOnpointerlockerror, setOnpointermove, setOnpointerout, setOnpointerover, setOnpointerup, setOnprogress, setOnratechange, setOnreadystatechange, setOnreset, setOnresize, setOnscroll, setOnsearch, setOnseeked, setOnseeking, setOnselect, setOnselectionchange, setOnselectstart, setOnstalled, setOnsubmit, setOnsuspend, setOntimeupdate, setOntoggle, setOnvolumechange, setOnwaiting, setOnwebkitfullscreenchange, setOnwebkitfullscreenerror, setOnwheel, setVlinkColor, setWindowafter, append, before, cloneNode, compareDocumentPosition, getAttributes, getChildNodes, getFirstChild, getJavaScriptNode, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParent, getParentElement, getParentNode, getPrefix, getPreviousSibling, getRootNode, getTextContent, hasAttributes, hasChildNodes, insertBefore, insertBeforeImpl, isEqualNode, isSameNode, lookupPrefix, normalize, prepend, remove, removeChild, replaceChild, replaceChildren, replaceWith, setNodeValue, setTextContentaddEventListener, clearEventListenersContainer, executeEventLocally, fireEvent, getEventHandler, getEventListenersContainer, hasEventHandlers, isEventHandlerOnWindow, removeEventListener, setEventHandlerclone, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrNull, getPrototype, getScriptableFor, getWindow, getWindow, getWindowFromTopCallScope, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setParentScope, setupPromise, setupRejectedPromiseapplyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkSlotRemoval, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, sizecreateSlotMappublic void jsConstructor()
jsConstructor in class Documentpublic DomNode getDomNodeOrDie()
getDomNodeOrDie in class HtmlUnitScriptablepublic HtmlPage getPage()
public static void write(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function)
context - the JavaScript contextscope - the scopethisObj - the scriptableargs - the arguments passed into the methodfunction - the functionpublic static void writeln(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function)
context - the JavaScript contextscope - the scopethisObj - the scriptableargs - the arguments passed into the methodfunction - the functionpublic void setExecutingDynamicExternalPosponed(boolean executing)
executing - indicates if executing or notprotected void write(String content)
See http://www.whatwg.org/specs/web-apps/current-work/multipage/section-dynamic.html for a good description of the semantics of open(), write(), writeln() and close().
content - the content to writepublic HTMLDocument open(Object url, Object name, Object features, Object replace)
See http://www.whatwg.org/specs/web-apps/current-work/multipage/section-dynamic.html for a good description of the semantics of open(), write(), writeln() and close().
url - when a new document is opened, url is a String that specifies a MIME type for the document.
        When a new window is opened, url is a String that specifies the URL to render in the new windowname - the namefeatures - the featuresreplace - whether to replace in the history list or nopublic void close()
           throws IOException
close.
 See http://www.whatwg.org/specs/web-apps/current-work/multipage/section-dynamic.html for a good description of the semantics of open(), write(), writeln() and close().
close in class DocumentIOException - if an IO problem occurspublic Element getDocumentElement()
documentElement for the document.getDocumentElement in class Documentpublic Node appendChild(Object childObject)
appendChild in class NodechildObject - the node to add to this nodepublic HtmlUnitScriptable getElementById(String id)
null if that element could not be found.getElementById in class Documentid - the ID to search fornull if it could not be foundpublic HTMLCollection getElementsByClassName(String className)
getElementsByClassName in class DocumentclassName - the name to search forpublic NodeList getElementsByName(String elementName)
name attribute with the specified value.
 Refer to The DOM spec for details.
getElementsByName in class DocumentelementName - - value of the name attribute to look forname attribute with the specified valueprotected Object getWithPreemption(String name)
document.XYZ should first look at elements named XYZ before
 using standard functions.
 
Called by HtmlUnitScriptable.get(String, Scriptable) to allow retrieval of the property before the prototype
 chain is searched.
IMPORTANT: This method is invoked *very* often by Rhino. If you override this method, the implementation needs to be as fast as possible!
getWithPreemption in class HtmlUnitScriptablename - the property nameScriptable.NOT_FOUND if not foundpublic HTMLElement getHead()
head element.public String getTitle()
public void setTitle(String title)
public HTMLElement getActiveElement()
activeElement property.getActiveElement in class DocumentactiveElement propertypublic boolean hasFocus()
false if the active element in the document has no focus;
 true if the active element in the document has focus.public boolean dispatchEvent(Event event)
dispatchEvent in class EventTargetevent - the event to be dispatchedfalse if at least one of the event handlers which handled the event
         called preventDefault; true otherwisepublic Selection getSelection()
getSelection in class Documentpublic Attr createAttribute(String attributeName)
createAttribute in class DocumentattributeName - the name of the attribute to createpublic String getBaseURI()
getBaseURI in class Nodepublic HtmlUnitScriptable elementFromPoint(int x, int y)
elementFromPoint in class Documentx - the x offset, in pixelsy - the y offset, in pixelsCopyright © 2002–2025 Gargoyle Software Inc.. All rights reserved.