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 |
captureEvents(String type)
Does nothing special anymore.
|
void |
clear()
Does... nothing.
|
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.
|
boolean |
execCommand(String cmd,
boolean userInterface,
Object value)
Executes a command.
|
HTMLElement |
getActiveElement()
Returns the value of the
activeElement property. |
String |
getAlinkColor()
Returns the value of the
alinkColor property. |
HTMLCollection |
getAll()
Returns the value of the
all property. |
Object |
getAnchors()
Returns the value of the JavaScript property
anchors. |
Object |
getApplets()
Returns the value of the JavaScript property
applets. |
String |
getBaseURI()
Returns the Base URI as a string.
|
String |
getBgColor()
Returns the value of the
bgColor property. |
HTMLElement |
getBody()
Returns this document's
body element. |
String |
getCookie()
Returns the
cookie property. |
String |
getDesignMode()
Returns a value which indicates whether or not the document can be edited.
|
Element |
getDocumentElement()
Gets the JavaScript property
documentElement for the document. |
String |
getDomain()
Returns the domain name of the server that served the document, or
null if the server
cannot be identified by a domain name. |
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. |
Object |
getEmbeds()
Returns the value of the
embeds property. |
String |
getFgColor()
Returns the value of the
fgColor property. |
Object |
getForms()
Returns the value of the
forms property. |
HTMLElement |
getHead()
Returns this document's
head element. |
Object |
getImages()
Returns the value of the
embeds property. |
String |
getLinkColor()
Returns the value of the
linkColor property. |
Object |
getLinks()
Returns the value of the JavaScript property
links. |
HtmlPage |
getPage()
Returns the HTML page that this document is modeling.
|
Object |
getParentWindow()
Gets the window in which this document is contained.
|
Object |
getPlugins()
Returns the value of the
plugins property. |
Object |
getScripts()
Returns the value of the
scripts property. |
Selection |
getSelection()
Returns the current selection.
|
String |
getTitle()
Returns this document's title.
|
String |
getVlinkColor()
Returns the value of the
vlinkColor property. |
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".
|
boolean |
queryCommandEnabled(String cmd)
Indicates if the command can be successfully executed using execCommand, given
the current state of the document.
|
boolean |
queryCommandSupported(String cmd)
Indicates if the command is supported.
|
void |
releaseEvents(String type)
Does nothing special anymore.
|
void |
setActiveElement(HTMLElement element)
Sets the specified element as the document's active element.
|
void |
setAlinkColor(String color)
Sets the value of the
alinkColor property. |
void |
setBgColor(String color)
Sets the value of the
bgColor property. |
void |
setCookie(String newCookie)
Adds a cookie, as long as cookies are enabled.
|
void |
setDesignMode(String mode)
Sets a value which indicates whether or not the document can be edited.
|
void |
setDomain(String newDomain)
Sets the domain of this document.
|
void |
setExecutingDynamicExternalPosponed(boolean executing)
This a hack!!!
|
void |
setFgColor(String color)
Sets the value of the
fgColor property. |
void |
setHead(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject head)
Sets the head.
|
void |
setLinkColor(String color)
Sets the value of the
linkColor property. |
void |
setTitle(String title)
Sets this document's title.
|
void |
setVlinkColor(String color)
Sets the value of the
vlinkColor property. |
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, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEvent, createNodeIterator, createNSResolver, createProcessingInstruction, createRange, createTextNode, createTreeWalker, evaluate, forceDocumentMode, get, getCharacterSet, getCharset, getChildElementCount, getChildren, getCompatMode, getContentType, getCurrentScript, getDefaultCharset, getDefaultView, getDoctype, getDocumentMode, getDocumentURI, getElementsByTagName, getElementsByTagNameNS, getFirstElementChild, getFonts, getFrames, getHidden, getImplementation, getInputEncoding, getLastElementChild, getLastModified, 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, getOnmozpointerlockchange, getOnmozpointerlockerror, 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, getOnshow, getOnstalled, getOnstop, getOnstoragecommit, getOnsubmit, getOnsuspend, getOntimeupdate, getOntoggle, getOnvolumechange, getOnwaiting, getOnwebkitfullscreenchange, getOnwebkitfullscreenerror, getOnwheel, getReadyState, getReferrer, getRootElement, getStyleSheets, getUniqueID, getURL, getURLUnencoded, getXmlEncoding, getXmlVersion, importNode, isReadOnlySettable, isXmlStandalone, querySelector, querySelectorAll, releaseCapture, setCurrentScript, 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, setOnmozpointerlockchange, setOnmozpointerlockerror, 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, setOnshow, setOnstalled, setOnstop, setOnstoragecommit, setOnsubmit, setOnsuspend, setOntimeupdate, setOntoggle, setOnvolumechange, setOnwaiting, setOnwebkitfullscreenchange, setOnwebkitfullscreenerror, setOnwheel, setWindowafter, asJavaScriptException, before, cloneNode, compareDocumentPosition, contains, getAttributes, getChildNodes, getFirstChild, getJavaScriptNode, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParent, getParentElement, getParentNode, getPrefix, getPreviousSibling, getTextContent, hasAttributes, hasChildNodes, insertBefore, insertBeforeImpl, isSameNode, normalize, remove, removeChild, replaceChild, replaceWith, setNodeValue, setTextContentaddEventListener, clearEventListenersContainer, executeEventLocally, fireEvent, getEventHandler, getEventListenersContainer, hasEventHandlers, isEventHandlerOnWindow, removeEventListener, setEventHandlerclone, equivalentValues, getBrowserVersion, getDefaultValue, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, has, hasInstance, initParentScope, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElementdefineFunctionProperties, defineProperty, getClassName, put, setClassName, setParentScopeapplyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, 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, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, 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, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setPrototype, sizepublic DomNode getDomNodeOrDie()
getDomNodeOrDie in class SimpleScriptablepublic HtmlPage getPage()
public Object getForms()
forms property.public Object getEmbeds()
embeds property.public Object getPlugins()
plugins property.getPlugins in class Documentplugins propertypublic Object getLinks()
links. Refer also to the
MSDN documentation.public Object getAnchors()
anchors.getAnchors in class Documentpublic Object getApplets()
applets.getApplets in class Documentpublic 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)
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 getImages()
embeds property.public HTMLCollection getAll()
all property.all propertypublic Object open(Object url, Object name, Object features, Object replace)
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 boolean execCommand(String cmd, boolean userInterface, Object value)
execCommand in class Documentcmd - the command identifieruserInterface - display a user interface if the command supports onevalue - the string, number, or other value to assign (possible values depend on the command)true if the command was successful, false otherwisepublic boolean queryCommandEnabled(String cmd)
queryCommandEnabled in class Documentcmd - the command identifiertrue if the command can be successfully executedpublic boolean queryCommandSupported(String cmd)
queryCommandSupported in class Documentcmd - the command identifiertrue if the command is supportedpublic Object getParentWindow()
public Object appendChild(Object childObject)
appendChild in class NodechildObject - the node to add to this nodepublic Object 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 HTMLCollection 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)
Called by SimpleScriptable.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 SimpleScriptablename - the property nameScriptable.NOT_FOUND if not foundpublic HTMLElement getHead()
head element.public HTMLElement getBody()
body element.public String getTitle()
public void setTitle(String title)
public String getBgColor()
bgColor property.getBgColor in class DocumentbgColor propertypublic void setBgColor(String color)
bgColor property.setBgColor in class Documentcolor - the value of the bgColor propertypublic String getAlinkColor()
alinkColor property.getAlinkColor in class DocumentalinkColor propertypublic void setAlinkColor(String color)
alinkColor property.setAlinkColor in class Documentcolor - the value of the alinkColor propertypublic String getLinkColor()
linkColor property.getLinkColor in class DocumentlinkColor propertypublic void setLinkColor(String color)
linkColor property.setLinkColor in class Documentcolor - the value of the linkColor propertypublic String getVlinkColor()
vlinkColor property.getVlinkColor in class DocumentvlinkColor propertypublic void setVlinkColor(String color)
vlinkColor property.setVlinkColor in class Documentcolor - the value of the vlinkColor propertypublic String getFgColor()
fgColor property.getFgColor in class DocumentfgColor propertypublic void setFgColor(String color)
fgColor property.setFgColor in class Documentcolor - the value of the fgColor propertypublic String getDomain()
null if the server
cannot be identified by a domain name.getDomain in class Documentpublic void setDomain(String newDomain)
The domain will be set according to the following rules:
TODO This code could be modified to understand country domain suffixes. The domain www.bbc.co.uk should be trimmable only down to bbc.co.uk trimming to co.uk should not be possible.
public Object getScripts()
scripts property.getScripts in class Documentscripts propertypublic 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 void setActiveElement(HTMLElement element)
element - the new active element for this documentHTMLElement.setActive()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 void clear()
public void setHead(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject head)
head - the headpublic 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 void captureEvents(String type)
captureEvents in class Documenttype - the type of events to captureWindow.captureEvents(String)public void releaseEvents(String type)
releaseEvents in class Documenttype - the type of events to captureWindow.releaseEvents(String)public String getDesignMode()
getDesignMode in class Documentpublic void setDesignMode(String mode)
setDesignMode in class Documentmode - a value which indicates whether or not the document can be editedpublic Object elementFromPoint(int x, int y)
elementFromPoint in class Documentx - the x offset, in pixelsy - the y offset, in pixelsCopyright © 2002–2020 Gargoyle Software Inc.. All rights reserved.