public class HTMLDocument extends Document
HTMLDocument
.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
Constructor and Description |
---|
HTMLDocument()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
Object |
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).
|
Object |
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
activeElement property. |
String |
getBaseURI()
Returns the Base URI as a string.
|
String |
getCookie()
Returns the
cookie property. |
Element |
getDocumentElement()
Gets the JavaScript property
documentElement for the document. |
DomNode |
getDomNodeOrDie()
Returns the DOM node that corresponds to this JavaScript object or throw
an exception if one cannot be found.
|
Object |
getElementById(String id)
Returns the element with the specified ID, or
null if that element could not be found. |
HTMLCollection |
getElementsByClassName(String className)
Returns all the descendant elements with the specified class name.
|
HTMLCollection |
getElementsByName(String elementName)
Returns all HTML elements that have a
name attribute with the specified value. |
HTMLElement |
getHead()
Returns this document's
head element. |
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.XYZ should first look at elements named XYZ before
using standard functions. |
boolean |
hasFocus()
Returns
false if the active element in the document has no focus;
true if the active element in the document has focus. |
Object |
open(Object url,
Object name,
Object features,
Object replace)
JavaScript function "open".
|
void |
setActiveElement(HTMLElement element)
Sets the specified element as the document's active element.
|
void |
setCookie(String newCookie)
Adds a cookie, as long as cookies are enabled.
|
void |
setExecutingDynamicExternalPosponed(boolean executing)
This a hack!!! A cleaner way is welcome.
|
void |
setHead(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject head)
Sets the head.
|
void |
setTitle(String title)
Sets this document's title.
|
static void |
write(net.sourceforge.htmlunit.corejs.javascript.Context context,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
Object[] args,
net.sourceforge.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(net.sourceforge.htmlunit.corejs.javascript.Context context,
net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
Object[] args,
net.sourceforge.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, get, getAlinkColor, getAll, getAnchors, getApplets, getBgColor, getBody, getCharacterSet, getCharset, getChildElementCount, getChildren, getCompatMode, getContentType, getCurrentScript, getDefaultCharset, getDefaultView, getDesignMode, getDoctype, getDocumentMode, getDocumentURI, getDomain, getElementsByTagName, getElementsByTagNameNS, getEmbeds, getFgColor, getFirstElementChild, getFonts, getForms, getFrames, getHidden, getImages, getImplementation, getInputEncoding, getLastElementChild, getLastModified, getLinkColor, getLinks, getLocation, getOnabort, getOnactivate, getOnafterscriptexecute, getOnauxclick, getOnbeforeactivate, getOnbeforecopy, getOnbeforecut, getOnbeforedeactivate, getOnbeforepaste, getOnbeforescriptexecute, getOnblur, getOncancel, getOncanplay, getOncanplaythrough, getOnchange, getOnclick, getOnclose, getOncontextmenu, getOncopy, getOncuechange, getOncut, getOndblclick, getOndeactivate, getOndrag, getOndragend, getOndragenter, getOndragleave, getOndragover, getOndragstart, getOndrop, getOndurationchange, getOnemptied, getOnended, getOnerror, getOnfocus, getOnfocusin, getOnfocusout, getOngotpointercapture, getOnhelp, getOninput, getOninvalid, getOnkeydown, getOnkeypress, getOnkeyup, getOnload, getOnloadeddata, getOnloadedmetadata, getOnloadstart, getOnlostpointercapture, getOnmousedown, getOnmouseenter, getOnmouseleave, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnmousewheel, getOnmozfullscreenchange, getOnmozfullscreenerror, getOnmscontentzoom, getOnmsfullscreenchange, getOnmsfullscreenerror, getOnmsgesturechange, getOnmsgesturedoubletap, getOnmsgestureend, getOnmsgesturehold, getOnmsgesturestart, getOnmsgesturetap, getOnmsinertiastart, getOnmsmanipulationstatechanged, getOnmspointercancel, getOnmspointerdown, getOnmspointerenter, getOnmspointerleave, getOnmspointermove, getOnmspointerout, getOnmspointerover, getOnmspointerup, getOnmssitemodejumplistitemremoved, getOnmsthumbnailclick, 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, getOnstop, getOnstoragecommit, getOnsubmit, getOnsuspend, getOntimeupdate, getOntoggle, getOnvolumechange, getOnwaiting, getOnwebkitfullscreenchange, getOnwebkitfullscreenerror, getOnwheel, getParentWindow, getPlugins, getReadyState, getReferrer, getRootElement, getScripts, getStyleSheets, getUniqueID, getURL_js, getURLUnencoded_js, getVlinkColor, getXmlEncoding, getXmlVersion, importNode, isXmlStandalone, queryCommandEnabled, queryCommandSupported, querySelector, querySelectorAll, releaseCapture, releaseEvents, setAlinkColor, setBgColor, setBody, setCurrentScript, setDesignMode, setDomain, setFgColor, setLinkColor, setLocation, setOnabort, setOnactivate, setOnafterscriptexecute, setOnauxclick, setOnbeforeactivate, setOnbeforecopy, setOnbeforecut, setOnbeforedeactivate, setOnbeforepaste, setOnbeforescriptexecute, setOnblur, setOncancel, setOncanplay, setOncanplaythrough, setOnchange, setOnclick, setOnclose, setOncontextmenu, setOncopy, setOncuechange, setOncut, setOndblclick, setOndeactivate, setOndrag, setOndragend, setOndragenter, setOndragleave, setOndragover, setOndragstart, setOndrop, setOndurationchange, setOnemptied, setOnended, setOnerror, setOnfocus, setOnfocusin, setOnfocusout, setOngotpointercapture, setOnhelp, setOninput, setOninvalid, setOnkeydown, setOnkeypress, setOnkeyup, setOnload, setOnloadeddata, setOnloadedmetadata, setOnloadstart, setOnlostpointercapture, setOnmousedown, setOnmouseenter, setOnmouseleave, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnmousewheel, setOnmozfullscreenchange, setOnmozfullscreenerror, setOnmscontentzoom, setOnmsfullscreenchange, setOnmsfullscreenerror, setOnmsgesturechange, setOnmsgesturedoubletap, setOnmsgestureend, setOnmsgesturehold, setOnmsgesturestart, setOnmsgesturetap, setOnmsinertiastart, setOnmsmanipulationstatechanged, setOnmspointercancel, setOnmspointerdown, setOnmspointerenter, setOnmspointerleave, setOnmspointermove, setOnmspointerout, setOnmspointerover, setOnmspointerup, setOnmssitemodejumplistitemremoved, setOnmsthumbnailclick, 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, setOnstop, setOnstoragecommit, setOnsubmit, setOnsuspend, setOntimeupdate, setOntoggle, setOnvolumechange, setOnwaiting, setOnwebkitfullscreenchange, setOnwebkitfullscreenerror, setOnwheel, setVlinkColor, setWindow
after, asJavaScriptException, 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, isSameNode, normalize, remove, removeChild, replaceChild, replaceWith, setNodeValue, setTextContent
addEventListener, clearEventListenersContainer, executeEventLocally, fireEvent, getEventHandler, getEventListenersContainer, hasEventHandlers, isEventHandlerOnWindow, removeEventListener, setEventHandler
clone, equivalentValues, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setParentScope
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, 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, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
public DomNode getDomNodeOrDie()
getDomNodeOrDie
in class HtmlUnitScriptable
public HtmlPage getPage()
public static void write(net.sourceforge.htmlunit.corejs.javascript.Context context, net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, net.sourceforge.htmlunit.corejs.javascript.Function function)
context
- the JavaScript contextthisObj
- the scriptableargs
- the arguments passed into the methodfunction
- the functionpublic static void writeln(net.sourceforge.htmlunit.corejs.javascript.Context context, net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, net.sourceforge.htmlunit.corejs.javascript.Function function)
context
- the JavaScript contextthisObj
- 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 String getCookie()
cookie
property.public void setCookie(String newCookie)
newCookie
- in the format "name=value[;expires=date][;domain=domainname][;path=path][;secure]public Object 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 Document
IOException
- if an IO problem occurspublic Element getDocumentElement()
documentElement
for the document.getDocumentElement
in class Document
public Object appendChild(Object childObject)
appendChild
in class Node
childObject
- the node to add to this nodepublic Object getElementById(String id)
null
if that element could not be found.getElementById
in class Document
id
- the ID to search fornull
if it could not be foundpublic HTMLCollection getElementsByClassName(String className)
getElementsByClassName
in class Document
className
- the name to search forpublic HTMLCollection getElementsByName(String elementName)
name
attribute with the specified value.
Refer to The DOM spec for details.
getElementsByName
in class Document
elementName
- - 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 HtmlUnitScriptable
name
- 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 Document
activeElement
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 void setActiveElement(HTMLElement element)
element
- the new active element for this documentHTMLElement.setActive()
public boolean dispatchEvent(Event event)
dispatchEvent
in class EventTarget
event
- the event to be dispatchedfalse
if at least one of the event handlers which handled the event
called preventDefault
; true
otherwisepublic void setHead(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject head)
head
- the headpublic Selection getSelection()
getSelection
in class Document
public Attr createAttribute(String attributeName)
createAttribute
in class Document
attributeName
- the name of the attribute to createpublic String getBaseURI()
getBaseURI
in class Node
public Object elementFromPoint(int x, int y)
elementFromPoint
in class Document
x
- the x offset, in pixelsy
- the y offset, in pixelsCopyright © 2002–2022 Gargoyle Software Inc.. All rights reserved.