- All Implemented Interfaces:
Serializable,Cloneable,org.htmlunit.corejs.javascript.ConstProperties<org.htmlunit.corejs.javascript.Scriptable>,org.htmlunit.corejs.javascript.debug.DebuggableObject,org.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>,org.htmlunit.corejs.javascript.Scriptable,org.htmlunit.corejs.javascript.SymbolScriptable
HTMLDocument.- Author:
- Mike Bowler, David K. Taylor, Chen Jun, Christian Sell, Chris Erskine, Marc Guillemot, Daniel Gredler, Michael Ottati, George Murnock, Ahmed Ashour, Rob Di Marco, Sudhan Moghe, Mike Dirolf, Ronald Brill, Frank Danek, Sven Strickroth
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.DescriptorInfo, org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator, org.htmlunit.corejs.javascript.ScriptableObject.LambdaGetterFunction, org.htmlunit.corejs.javascript.ScriptableObject.LambdaSetterFunction -
Field Summary
Fields inherited from class org.htmlunit.javascript.host.dom.Node
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_NODEFields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTFields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
isSealedFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappendChild(Object childObject) Adds a DOM node to the node.voidclose()JavaScript functionclose.createAttribute(String attributeName) Creates a new HTML attribute with the specified name.booleandispatchEvent(Event event) Dispatches an event into the event system (standards-conformant browsers only).elementFromPoint(int x, int y) Returns the element for the specified x coordinate and the specified y coordinate.Returns the value of theactiveElementproperty.Returns the Base URI as a string.Gets the JavaScript propertydocumentElementfor the document.Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.getElementById(String id) Returns the element with the specified ID, ornullif that element could not be found.getElementsByClassName(String className) Returns all the descendant elements with the specified class name.getElementsByName(String elementName) Returns all HTML elements that have anameattribute with the specified value.getHead()Returns this document'sheadelement.getPage()Returns the HTML page that this document is modeling.Returns the current selection.getTitle()Returns this document's title.protected ObjectgetWithPreemption(String name) Calls todocument.XYZshould first look at elements namedXYZbefore using standard functions.booleanhasFocus()Returnsfalseif the active element in the document has no focus;trueif the active element in the document has focus.voidJavaScript constructor.static voidmoveBefore(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Moves a given Node inside the invoking node as a direct child, before a given reference node.JavaScript function "open".static HTMLDocumentparseHTMLUnsafe(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function funObj) Parses the given string of HTML without sanitizing it and returns a new HTMLDocument.voidsetExecutingDynamicExternalPosponed(boolean executing) This a hack!!!voidSets this document's title.protected voidJavaScript function "write".static voidwrite(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope 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.static voidwriteln(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope 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.Methods inherited from class org.htmlunit.javascript.host.dom.Document
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, setWindowMethods inherited from class org.htmlunit.javascript.host.dom.Node
after, 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, setTextContentMethods inherited from class org.htmlunit.javascript.host.event.EventTarget
addEventListener, clearEventListenersContainer, executeEventLocally, fireEvent, getEventHandler, getEventListenersContainer, hasEventHandlers, isEventHandlerOnWindow, removeEventListener, setEventHandlerMethods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrNull, getPrototype, getScriptableFor, getWindow, getWindow, getWindowOrWorkerGlobalScope, has, hasInstance, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setupPromise, setupRejectedPromiseMethods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, 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, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getThis, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasProperty, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isTrue, preventExtensions, put, put, putConst, putConstProperty, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, redefineProperty, sameValue, sealObject, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, sizeMethods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, defineProperty, defineProperty, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getIds, has, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMapsMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.htmlunit.corejs.javascript.Scriptable
get, getIds, has, hasMethods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable
get, has
-
Constructor Details
-
HTMLDocument
public HTMLDocument()
-
-
Method Details
-
jsConstructor
public void jsConstructor()JavaScript constructor.- Overrides:
jsConstructorin classDocument
-
getDomNodeOrDie
Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.- Overrides:
getDomNodeOrDiein classHtmlUnitScriptable- Returns:
- the DOM node
-
getPage
Returns the HTML page that this document is modeling. -
parseHTMLUnsafe
public static HTMLDocument parseHTMLUnsafe(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function funObj) Parses the given string of HTML without sanitizing it and returns a new HTMLDocument.- Parameters:
cx- the current contextscope- the scopethisObj- the scriptable this objectargs- the argumentsfunObj- the function object- Returns:
- a newly created
HTMLDocument - See Also:
-
write
public static void write(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope 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.- Parameters:
context- the JavaScript contextscope- the scopethisObj- the scriptableargs- the arguments passed into the methodfunction- the function- See Also:
-
moveBefore
public static void moveBefore(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Moves a given Node inside the invoking node as a direct child, before a given reference node.- Parameters:
context- the JavaScript contextscope- the scopethisObj- the scriptableargs- the arguments passed into the methodfunction- the function
-
writeln
public static void writeln(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope 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.- Parameters:
context- the JavaScript contextscope- the scopethisObj- the scriptableargs- the arguments passed into the methodfunction- the function- See Also:
-
setExecutingDynamicExternalPosponed
public void setExecutingDynamicExternalPosponed(boolean executing) This a hack!!! A cleaner way is welcome. Handle a case where document.write() is simply ignored. See HTMLDocumentWrite2Test.write_fromScriptAddedWithAppendChild_external.- Parameters:
executing- indicates if executing or not
-
write
JavaScript function "write".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().
- Parameters:
content- the content to write
-
open
JavaScript function "open".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().
- Parameters:
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 no- Returns:
- a reference to the new document object.
- See Also:
-
close
JavaScript functionclose.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().
- Overrides:
closein classDocument- Throws:
IOException- if an IO problem occurs
-
getDocumentElement
Gets the JavaScript propertydocumentElementfor the document.- Overrides:
getDocumentElementin classDocument- Returns:
- the root node for the document
-
appendChild
Adds a DOM node to the node.- Overrides:
appendChildin classNode- Parameters:
childObject- the node to add to this node- Returns:
- the newly added child node
-
getElementById
Returns the element with the specified ID, ornullif that element could not be found.- Overrides:
getElementByIdin classDocument- Parameters:
id- the ID to search for- Returns:
- the element, or
nullif it could not be found
-
getElementsByClassName
Returns all the descendant elements with the specified class name.- Overrides:
getElementsByClassNamein classDocument- Parameters:
className- the name to search for- Returns:
- all the descendant elements with the specified class name
- See Also:
-
getElementsByName
Returns all HTML elements that have anameattribute with the specified value.Refer to The DOM spec for details.
- Overrides:
getElementsByNamein classDocument- Parameters:
elementName- - value of thenameattribute to look for- Returns:
- all HTML elements that have a
nameattribute with the specified value
-
getWithPreemption
Calls todocument.XYZshould first look at elements namedXYZbefore 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!
- Overrides:
getWithPreemptionin classHtmlUnitScriptable- Parameters:
name- the property name- Returns:
Scriptable.NOT_FOUNDif not found
-
getHead
Returns this document'sheadelement. -
getTitle
Returns this document's title. -
setTitle
Sets this document's title. -
getActiveElement
Returns the value of theactiveElementproperty.- Overrides:
getActiveElementin classDocument- Returns:
- the value of the
activeElementproperty - See Also:
-
hasFocus
public boolean hasFocus()Returnsfalseif the active element in the document has no focus;trueif the active element in the document has focus. -
dispatchEvent
Dispatches an event into the event system (standards-conformant browsers only). See the Gecko DOM reference for more information.- Overrides:
dispatchEventin classEventTarget- Parameters:
event- the event to be dispatched- Returns:
falseif at least one of the event handlers which handled the event calledpreventDefault;trueotherwise
-
getSelection
Returns the current selection.- Overrides:
getSelectionin classDocument- Returns:
- the current selection
-
createAttribute
Creates a new HTML attribute with the specified name.- Overrides:
createAttributein classDocument- Parameters:
attributeName- the name of the attribute to create- Returns:
- an attribute with the specified name
-
getBaseURI
Returns the Base URI as a string.- Overrides:
getBaseURIin classNode- Returns:
- the Base URI as a string
-
elementFromPoint
Returns the element for the specified x coordinate and the specified y coordinate. The current implementation always returns null element.- Overrides:
elementFromPointin classDocument- Parameters:
x- the x offset, in pixelsy- the y offset, in pixels- Returns:
- the element for the specified x coordinate and the specified y coordinate
-