public class HTMLDocument extends Document implements ScriptableWithFallbackGetter
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 |
clear()
Does...
|
void |
close()
JavaScript function "close".
|
Attr |
createAttribute(String attributeName)
Creates a new HTML attribute with the specified name.
|
Event |
createEvent(String eventType)
Implementation of the
DocumentEvent interface's
DocumentEvent method. |
NodeIterator |
createNodeIterator(Node root,
double whatToShow,
net.sourceforge.htmlunit.corejs.javascript.Scriptable filter)
Returns a new NodeIterator object.
|
Range |
createRange()
Creates and returns a new range.
|
Object |
createTreeWalker(Node root,
double whatToShow,
net.sourceforge.htmlunit.corejs.javascript.Scriptable filter,
boolean expandEntityReferences)
Creates and returns a new TreeWalker.
|
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.
|
void |
forceDocumentMode(int documentMode)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Called from the HTMLParser if a 'X-UA-Compatible' meta tag found. |
Object |
get(String name,
net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
Gets a named property from the object.
|
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 URL to resolve relative URLs.
|
String |
getBgColor()
Returns the value of the
bgColor property. |
HTMLElement |
getBody()
Returns this document's
body element. |
String |
getCharacterSet()
Returns the character encoding of the current document.
|
String |
getCharset()
Retrieves the character set used to encode the document.
|
String |
getCompatMode()
Returns the
compatMode property. |
String |
getCookie()
Returns the
cookie property. |
String |
getDefaultCharset()
Gets the default character set from the current regional language settings.
|
int |
getDocumentMode()
Returns the
documentMode property. |
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. |
String |
getFgColor()
Returns the value of the
fgColor property. |
Object |
getForms()
Returns the value of the JavaScript property
forms . |
Object |
getFrames()
Returns the value of the
frames property. |
HTMLElement |
getHead()
Returns this document's
head element. |
Object |
getImages()
Returns the value of the
images property. |
String |
getInputEncoding()
Returns a string representing the encoding under which the document was parsed.
|
String |
getLastModified()
Returns the last modification date of the document.
|
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.
|
String |
getReadyState()
Returns the ready state of the document.
|
Object |
getScripts()
Returns the value of the
scripts property. |
Selection |
getSelection()
Returns the current selection.
|
StyleSheetList |
getStyleSheets()
Retrieves a collection of stylesheet objects representing the style sheets that correspond
to each instance of a Link or
CSSStyleDeclaration object in the document. |
String |
getTitle()
Returns this document's title.
|
String |
getUniqueID()
Retrieves an auto-generated, unique identifier for the object.
|
String |
getURL()
Returns the value of the
URL property. |
String |
getVlinkColor()
Returns the value of the
vlinkColor property. |
Object |
getWithFallback(String name)
Looks at properties with the specified name.
|
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(String 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.
|
Node |
querySelector(String selectors)
Returns the first element within the document that matches the specified group of selectors.
|
NodeList |
querySelectorAll(String selectors)
Retrieves all element nodes from descendants of the starting element node that match any selector
within the supplied selector strings.
|
boolean |
releaseCapture()
Mock for the moment.
|
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 |
setDomain(String newDomain)
Sets the domain of this document.
|
void |
setExecutingDynamicExternalPosponed(boolean executing)
This a hack!!! A cleaner way is welcome.
|
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, captureEvents, createComment, createDocumentFragment, createElement, createElementNS, createNSResolver, createTextNode, evaluate, getDefaultView, getDesignMode, getDoctype, getDocumentElement, getElementsByTagName, getElementsByTagNameNS, getImplementation, getLocation, getReferrer, importNode, setDesignMode, setLocation, setWindow
fireEvent, getOnblur, getOnclick, getOncontextmenu, getOndblclick, getOnerror, getOnfocus, getOnfocusin, getOnfocusout, getOninput, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnpropertychange, getOnresize, setOnblur, setOnclick, setOncontextmenu, setOndblclick, setOnerror, setOnfocus, setOnfocusin, setOnfocusout, setOninput, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnpropertychange, setOnresize
asJavaScriptException, cloneNode, compareDocumentPosition, contains, detachEvent, getAttributes, getChildNodes, getFirstChild, getJavaScriptNode, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParent, getParentElement, getParentNode, getPrefix, getPreviousSibling, getTextContent, hasChildNodes, insertBefore, insertBeforeImpl, isSameNode, normalize, remove, removeChild, replaceChild, setNodeValue, setTextContent
addEventListener, clearEventListenersContainer, executeEventLocally, fireEvent, getEventHandler, getEventHandlerProp, getEventListenersContainer, hasEventHandlers, removeEventListener, setEventHandler, setEventHandlerProp
clone, equivalentValues, getBrowserVersion, getDefaultValue, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, has, hasInstance, initParentScope, isReadOnlySettable, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElement
defineFunctionProperties, defineProperty, getClassName, setClassName, setParentScope
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setPrototype, size
public DomNode getDomNodeOrDie()
getDomNodeOrDie
in class SimpleScriptable
public HtmlPage getPage()
public Object getForms()
forms
.forms
public Object getLinks()
links
. Refer also to the
MSDN documentation.public String getLastModified()
public Object getAnchors()
anchors
.public Object getApplets()
applets
.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)
content
- the content to writepublic String getBaseURI()
public String getCookie()
cookie
property.cookie
propertypublic String getCompatMode()
compatMode
property.
Note that it is deprecated in Internet Explorer 8 in favor of the documentMode
.compatMode
propertypublic int getDocumentMode()
documentMode
property.documentMode
propertypublic void forceDocumentMode(int documentMode)
documentMode
- the mode forced by the meta tagpublic void setCookie(String newCookie)
newCookie
- in the format "name=value[;expires=date][;domain=domainname][;path=path][;secure]public Object getImages()
images
property.images
propertypublic String getInputEncoding()
public String getCharacterSet()
public String getCharset()
public String getDefaultCharset()
public String getURL()
URL
property.URL
propertypublic String getUniqueID()
public HTMLCollection getAll()
all
property.all
propertypublic Object open(String 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
IOException
- if an IO problem occurspublic Object getParentWindow()
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.id
- the ID to search fornull
if it could not be foundpublic HTMLCollection getElementsByClassName(String className)
className
- the name to search forpublic HTMLCollection getElementsByName(String elementName)
name
attribute with the specified value.
Refer to
The DOM spec for details.elementName
- - 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 SimpleScriptable
name
- the property nameScriptable.NOT_FOUND
if not foundpublic Object getWithFallback(String name)
Scriptable
object.getWithFallback
in interface ScriptableWithFallbackGetter
name
- the name of the requested propertyScriptable.NOT_FOUND
if nothing is foundpublic HTMLElement getBody()
body
element.body
elementpublic HTMLElement getHead()
head
element.head
elementpublic String getTitle()
public void setTitle(String title)
title
- the new titlepublic String getBgColor()
bgColor
property.bgColor
propertypublic void setBgColor(String color)
bgColor
property.color
- the value of the bgColor
propertypublic String getAlinkColor()
alinkColor
property.alinkColor
propertypublic void setAlinkColor(String color)
alinkColor
property.color
- the value of the alinkColor
propertypublic String getLinkColor()
linkColor
property.linkColor
propertypublic void setLinkColor(String color)
linkColor
property.color
- the value of the linkColor
propertypublic String getVlinkColor()
vlinkColor
property.vlinkColor
propertypublic void setVlinkColor(String color)
vlinkColor
property.color
- the value of the vlinkColor
propertypublic String getFgColor()
fgColor
property.fgColor
propertypublic void setFgColor(String color)
fgColor
property.color
- the value of the fgColor
propertypublic String getReadyState()
DomNode.READY_STATE_UNINITIALIZED
,
DomNode.READY_STATE_LOADING
,
DomNode.READY_STATE_LOADED
,
DomNode.READY_STATE_INTERACTIVE
,
DomNode.READY_STATE_COMPLETE
public String getDomain()
null
if the server
cannot be identified by a domain name.public void setDomain(String newDomain)
The domain will be set according to the following rules:
newDomain
- the new domain to setpublic Object getScripts()
scripts
property.scripts
propertypublic Object getFrames()
frames
property.public StyleSheetList getStyleSheets()
CSSStyleDeclaration
object in the document.public Event createEvent(String eventType) throws DOMException
DocumentEvent
interface's
DocumentEvent
method. The method creates an
uninitialized event of the specified type.eventType
- the event type to createDOMException
- if the event type is not supported (will have a type of
DOMException.NOT_SUPPORTED_ERR)public Object elementFromPoint(int x, int y)
x
- the x offset, in pixelsy
- the y offset, in pixelspublic Range createRange()
public Object createTreeWalker(Node root, double whatToShow, net.sourceforge.htmlunit.corejs.javascript.Scriptable filter, boolean expandEntityReferences) throws DOMException
null
.NodeFilter
for the set of possible Show_ values.NodeFilter
to be used with this TreeWalker, or null
to indicate no filter.false
, the contents of EntityReference nodes are not present
in the logical view.root
- the node which will serve as the root for the TreeWalkerwhatToShow
- specifies which node types may appear in the logical view of the tree presentedfilter
- the NodeFilter to be used with this TreeWalker, or null to indicate no filterexpandEntityReferences
- If false,
the contents of EntityReference nodes are not presented in the logical viewDOMException
- on attempt to create a TreeWalker with a root that is null
public boolean queryCommandSupported(String cmd)
cmd
- the command identifiertrue>
if the command is supportedpublic boolean queryCommandEnabled(String cmd)
cmd
- the command identifiertrue
if the command can be successfully executedpublic boolean execCommand(String cmd, boolean userInterface, Object value)
cmd
- 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 HTMLElement getActiveElement()
activeElement
property.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 NodeList querySelectorAll(String selectors)
selectors
- the selectorspublic Node querySelector(String selectors)
selectors
- the selectorspublic Object get(String name, net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
SimpleScriptable.getWithPreemption(String)
.
For fallback case just implement ScriptableWithFallbackGetter
.
get
in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
get
in class SimpleScriptable
public void clear()
public void setHead(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject head)
head
- the headpublic Selection getSelection()
public boolean releaseCapture()
public NodeIterator createNodeIterator(Node root, double whatToShow, net.sourceforge.htmlunit.corejs.javascript.Scriptable filter)
root
- The root node at which to begin the NodeIterator's traversal.whatToShow
- an optional long representing a bitmask created by combining
the constant properties of NodeFilter
filter
- an object implementing the NodeFilter
interfacepublic Attr createAttribute(String attributeName)
createAttribute
in class Document
attributeName
- the name of the attribute to createCopyright © 2002–2019 Gargoyle Software Inc.. All rights reserved.