com.gargoylesoftware.htmlunit.javascript.host.html
Class HTMLDocument

java.lang.Object
  extended by net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
      extended by com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
          extended by com.gargoylesoftware.htmlunit.javascript.host.Node
              extended by com.gargoylesoftware.htmlunit.javascript.host.EventNode
                  extended by com.gargoylesoftware.htmlunit.javascript.host.Document
                      extended by com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument
All Implemented Interfaces:
ScriptableWithFallbackGetter, Serializable, Cloneable, net.sourceforge.htmlunit.corejs.javascript.ConstProperties, net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableObject, net.sourceforge.htmlunit.corejs.javascript.Scriptable

public class HTMLDocument
extends Document
implements ScriptableWithFallbackGetter

A JavaScript object for a Document.

Version:
$Revision: 7650 $
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
See Also:
MSDN documentation, W3C DOM Level 1, Serialized Form

Field Summary
static String EMPTY_COOKIE_NAME
          The cookie name used for cookies with no name (HttpClient doesn't like empty names).
 
Fields inherited from class com.gargoylesoftware.htmlunit.javascript.host.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_NODE
 
Fields inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
HTMLDocument()
          Creates a new instance.
 
Method Summary
 Object appendChild(Object childObject)
          Adds a DOM node to the node.
static Cookie buildCookie(String newCookie, URL currentURL)
          Builds a cookie object from the string representation allowed in JS.
 void clear()
          Does...
 void close()
          JavaScript function "close".
 Object createElement(String tagName)
          Create a new HTML element with the given tag name.
 Event createEvent(String eventType)
          Implementation of the DocumentEvent interface's DocumentEvent method.
 Event createEventObject()
          Implementation of the createEventObject method supported by Internet Explorer.
 Range createRange()
          Creates and returns a new range.
 CSSStyleSheet createStyleSheet(String url, int index)
          Creates a new Stylesheet.
 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.
 Object get(String name, net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
          Gets a named property from the object.
 Object getActiveElement()
          Returns the value of the "activeElement" property.
 String getAlinkColor()
          Returns the value of the alinkColor attribute.
 HTMLCollection getAll()
          Returns the value of the "all" property.
 Object getAnchors()
          Returns the value of the JavaScript attribute "anchors".
 Object getApplets()
          Returns the value of the JavaScript attribute "applets".
 String getBgColor()
          Returns the value of the bgColor attribute.
 HTMLElement getBody()
          Returns this document's body element.
 String getCompatMode()
          Returns the "compatMode" attribute.
 String getCookie()
          Returns the cookie attribute.
 SimpleScriptable getDoctype()
          Gets the JavaScript property "doctype" 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.
<N extends DomNode>
N
getDomNodeOrDie()
          Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.
 DomNode getDomNodeOrNull()
          Returns the DOM node that corresponds to this JavaScript object or null if a node hasn't been set.
 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 attribute.
 Object getForms()
          Returns the value of the JavaScript attribute "forms".
 Object getFrames()
          Returns the value of the frames property.
 HTMLElement getHead()
          Returns this document's head element.
 HtmlPage getHtmlPage()
          Returns the HTML page that this document is modeling.
 HtmlPage getHtmlPageOrNull()
          Returns the HTML page that this document is modeling, or null if the page is empty.
 Object getImages()
          Returns the value of the "images" property.
 String getLastModified()
          Returns the last modification date of the document.
 String getLinkColor()
          Returns the value of the linkColor attribute.
 Object getLinks()
          Returns the value of the JavaScript attribute "links".
 Object getNamespaces()
          Returns the value of the JavaScript attribute "namespaces".
 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 JavaScript attribute scripts.
 Selection getSelection_js()
          Returns the value of the JavaScript attribute selection.
 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 attribute.
 Object getWithFallback(String name)
          Looks at attributes with the specified name.
protected  Object getWithPreemption(String name)
          Calls to document.XYZ should first look at elements named XYZ before using standard functions.
 SimpleScriptable makeScriptableFor(DomNode domNode)
          Builds a new the JavaScript object that corresponds to the specified object.
 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.
 StaticNodeList querySelectorAll(String selectors)
          Retrieves all element nodes from descendants of the starting element node that match any selector within the supplied selector strings.
 void setActiveElement(HTMLElement element)
          Sets the specified element as the document's active element.
 void setAlinkColor(String color)
          Sets the value of the alinkColor attribute.
 void setBgColor(String color)
          Sets the value of the bgColor attribute.
 void setCookie(String newCookie)
          Adds a cookie, as long as cookies are enabled.
 void setDomain(String newDomain)
          Sets the the domain of this document.
 void setFgColor(String color)
          Sets the value of the fgColor attribute.
 void setHead(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject head)
          Sets the head.
 void setLinkColor(String color)
          Sets the value of the linkColor attribute.
 void setTitle(String title)
          Sets this document's title.
 void setVlinkColor(String color)
          Sets the value of the vlinkColor attribute.
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.
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.host.Document
captureEvents, createAttribute, createComment, createDocumentFragment, createElementNS, createNSResolver, createTextNode, evaluate, getBoxObjectFor, getDefaultView, getDesignMode, getDocumentElement, getElementsByTagName, getElementsByTagNameNS, getImplementation, getLocation, getPage, getReferrer, importNode, setDesignMode, setLocation, setWindow
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.host.EventNode
fireEvent, getOnblur, getOnclick, getOncontextmenu, getOndblclick, getOnerror, getOnfocus, getOnfocusin, getOnfocusout, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnpropertychange, getOnresize, setOnblur, setOnclick, setOncontextmenu, setOndblclick, setOnerror, setOnfocus, setOnfocusin, setOnfocusout, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnpropertychange, setOnresize
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.host.Node
addEventListener, attachEvent, cloneNode, compareDocumentPosition, detachEvent, executeEvent, fireEvent, fireEvent, getAttributes, getChildNodes, getEventHandler, getEventHandlerProp, getFirstChild, getJavaScriptNode, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParent, getParentElement, getParentNode, getPrefix, getPreviousSibling, getTextContent, getXml, hasChildNodes, hasEventHandlers, insertBefore, insertBeforeImpl, isSameNode, normalize, removeChild, removeEventListener, replaceChild, setDomNode, setEventHandler, setEventHandlerProp, setNodeValue, setTextContent
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
clone, defineFunctionProperties, defineProperty, equivalentValues, getBrowserVersion, getClassName, getDefaultValue, getPrototype, getScriptableFor, getStartingScope, getTransformerScriptableFor, getWindow, getWindow, hasInstance, initParentScope, isReadOnlySettable, setCaseSensitive, setDomNode, setHtmlElement
 
Methods inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
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, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, 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, setGetterOrSetter, setParentScope, setPrototype, size
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
delete, delete, get, getClassName, getDefaultValue, getIds, getParentScope, getPrototype, has, has, hasInstance, put, put, setParentScope, setPrototype
 

Field Detail

EMPTY_COOKIE_NAME

public static final String EMPTY_COOKIE_NAME
The cookie name used for cookies with no name (HttpClient doesn't like empty names).

See Also:
Constant Field Values
Constructor Detail

HTMLDocument

public HTMLDocument()
Creates a new instance. JavaScript objects must have a default constructor.

Method Detail

getDomNodeOrDie

public <N extends DomNode> N getDomNodeOrDie()
                                  throws IllegalStateException
Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.

Overrides:
getDomNodeOrDie in class SimpleScriptable
Type Parameters:
N - the node type
Returns:
the DOM node
Throws:
IllegalStateException - If the DOM node could not be found.

getDomNodeOrNull

public DomNode getDomNodeOrNull()
Returns the DOM node that corresponds to this JavaScript object or null if a node hasn't been set.

Overrides:
getDomNodeOrNull in class SimpleScriptable
Returns:
the DOM node or null

getHtmlPage

public HtmlPage getHtmlPage()
Returns the HTML page that this document is modeling.

Returns:
the HTML page that this document is modeling

getHtmlPageOrNull

public HtmlPage getHtmlPageOrNull()
Returns the HTML page that this document is modeling, or null if the page is empty.

Returns:
the HTML page that this document is modeling, or null if the page is empty

getForms

public Object getForms()
Returns the value of the JavaScript attribute "forms".

Returns:
the value of the JavaScript attribute "forms"

getLinks

public Object getLinks()
Returns the value of the JavaScript attribute "links". Refer also to the MSDN documentation.

Returns:
the value of this attribute

getLastModified

public String getLastModified()
Returns the last modification date of the document.

Returns:
the date as string
See Also:
Mozilla documentation

getNamespaces

public Object getNamespaces()
Returns the value of the JavaScript attribute "namespaces".

Returns:
the value of the JavaScript attribute "namespaces"

getAnchors

public Object getAnchors()
Returns the value of the JavaScript attribute "anchors".

Returns:
the value of this attribute
See Also:
MSDN documentation, Gecko DOM reference

getApplets

public Object getApplets()
Returns the value of the JavaScript attribute "applets".

Returns:
the value of this attribute
See Also:
MSDN documentation, Gecko DOM reference

write

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)
JavaScript function "write" may accept a variable number of arguments. It's not documented by W3C, Mozilla or MSDN but works with Mozilla and IE.

Parameters:
context - the JavaScript context
thisObj - the scriptable
args - the arguments passed into the method
function - the function
See Also:
MSDN documentation

writeln

public 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. It's not documented by W3C, Mozilla or MSDN but works with Mozilla and IE.

Parameters:
context - the JavaScript context
thisObj - the scriptable
args - the arguments passed into the method
function - the function
See Also:
MSDN documentation

write

protected void write(String content)
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

getCookie

public String getCookie()
Returns the cookie attribute.

Returns:
the cookie attribute

getCompatMode

public String getCompatMode()
Returns the "compatMode" attribute. Note that it is deprecated in Internet Explorer 8 in favor of the documentMode.

Returns:
the "compatMode" attribute

setCookie

public void setCookie(String newCookie)
Adds a cookie, as long as cookies are enabled.

Parameters:
newCookie - in the format "name=value[;expires=date][;domain=domainname][;path=path][;secure]
See Also:
MSDN documentation

buildCookie

public static Cookie buildCookie(String newCookie,
                                 URL currentURL)
Builds a cookie object from the string representation allowed in JS.

Parameters:
newCookie - in the format "name=value[;expires=date][;domain=domainname][;path=path][;secure]
currentURL - the URL of the current page
Returns:
the cookie

getImages

public Object getImages()
Returns the value of the "images" property.

Returns:
the value of the "images" property

getURL

public String getURL()
Returns the value of the "URL" property.

Returns:
the value of the "URL" property

getUniqueID

public String getUniqueID()
Retrieves an auto-generated, unique identifier for the object. Note The unique ID generated is not guaranteed to be the same every time the page is loaded.

Returns:
an auto-generated, unique identifier for the object

getAll

public HTMLCollection getAll()
Returns the value of the "all" property.

Returns:
the value of the "all" property

open

public Object open(String url,
                   Object name,
                   Object features,
                   Object replace)
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 window
name - the name
features - the features
replace - whether to replace in the history list or no
Returns:
a reference to the new document object or the window object.
See Also:
MSDN documentation

close

public void close()
           throws IOException
JavaScript function "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().

Throws:
IOException - if an IO problem occurs

getParentWindow

public Object getParentWindow()
Gets the window in which this document is contained.

Returns:
the window

appendChild

public Object appendChild(Object childObject)
Adds a DOM node to the node.

Overrides:
appendChild in class Node
Parameters:
childObject - the node to add to this node
Returns:
the newly added child node

createElement

public Object createElement(String tagName)
Create a new HTML element with the given tag name.

Overrides:
createElement in class Document
Parameters:
tagName - the tag name
Returns:
the new HTML element, or NOT_FOUND if the tag is not supported

createStyleSheet

public CSSStyleSheet createStyleSheet(String url,
                                      int index)
Creates a new Stylesheet. Current implementation just creates an empty CSSStyleSheet object.

Parameters:
url - the stylesheet URL
index - where to insert the sheet in the collection
Returns:
the newly created stylesheet

getElementById

public Object getElementById(String id)
Returns the element with the specified ID, or null if that element could not be found.

Parameters:
id - the ID to search for
Returns:
the element, or null if it could not be found

getElementsByClassName

public HTMLCollection getElementsByClassName(String className)
Returns all the descendant elements with the specified class name.

Parameters:
className - the name to search for
Returns:
all the descendant elements with the specified class name
See Also:
Mozilla doc

getElementsByName

public HTMLCollection getElementsByName(String elementName)
Returns all HTML elements that have a "name" attribute with the specified value. Refer to The DOM spec for details.

Parameters:
elementName - - value of the "name" attribute to look for
Returns:
all HTML elements that have a "name" attribute with the specified value

getWithPreemption

protected Object getWithPreemption(String name)
Calls to document.XYZ should first look at elements named XYZ before using standard functions.

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!

Overrides:
getWithPreemption in class SimpleScriptable
Parameters:
name - the property name
Returns:
Scriptable.NOT_FOUND if not found

getWithFallback

public Object getWithFallback(String name)
Looks at attributes with the specified name. Fallback called when no configured property is found with the given name on the Scriptable object.

Specified by:
getWithFallback in interface ScriptableWithFallbackGetter
Parameters:
name - the name of the requested property
Returns:
the object value, Scriptable.NOT_FOUND if nothing is found

getBody

public HTMLElement getBody()
Returns this document's body element.

Returns:
this document's body element

getHead

public HTMLElement getHead()
Returns this document's head element.

Returns:
this document's head element

getTitle

public String getTitle()
Returns this document's title.

Returns:
this document's title

setTitle

public void setTitle(String title)
Sets this document's title.

Parameters:
title - the new title

getBgColor

public String getBgColor()
Returns the value of the bgColor attribute.

Returns:
the value of the bgColor attribute
See Also:
MSDN Documentation

setBgColor

public void setBgColor(String color)
Sets the value of the bgColor attribute.

Parameters:
color - the value of the bgColor attribute
See Also:
MSDN Documentation

getAlinkColor

public String getAlinkColor()
Returns the value of the alinkColor attribute.

Returns:
the value of the alinkColor attribute

setAlinkColor

public void setAlinkColor(String color)
Sets the value of the alinkColor attribute.

Parameters:
color - the value of the alinkColor attribute

getLinkColor

public String getLinkColor()
Returns the value of the linkColor attribute.

Returns:
the value of the linkColor attribute

setLinkColor

public void setLinkColor(String color)
Sets the value of the linkColor attribute.

Parameters:
color - the value of the linkColor attribute

getVlinkColor

public String getVlinkColor()
Returns the value of the vlinkColor attribute.

Returns:
the value of the vlinkColor attribute

setVlinkColor

public void setVlinkColor(String color)
Sets the value of the vlinkColor attribute.

Parameters:
color - the value of the vlinkColor attribute

getFgColor

public String getFgColor()
Returns the value of the fgColor attribute.

Returns:
the value of the fgColor attribute

setFgColor

public void setFgColor(String color)
Sets the value of the fgColor attribute.

Parameters:
color - the value of the fgColor attribute

getReadyState

public String getReadyState()
Returns the ready state of the document. This is an IE-only property.

Returns:
the ready state of the document
See Also:
DomNode.READY_STATE_UNINITIALIZED, DomNode.READY_STATE_LOADING, DomNode.READY_STATE_LOADED, DomNode.READY_STATE_INTERACTIVE, DomNode.READY_STATE_COMPLETE

getDomain

public 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.

Returns:
the domain name of the server that served the document
See Also:
W3C documentation

setDomain

public void setDomain(String newDomain)
Sets the the domain of this document. Domains can only be set to suffixes of the existing domain with the exception of setting the domain to itself.

The domain will be set according to the following rules:

  1. If the newDomain.equalsIgnoreCase(currentDomain) the method returns with no error.
  2. If the browser version is netscape, the newDomain is downshifted.
  3. The change will take place if and only if the suffixes of the current domain and the new domain match AND there are at least two domain qualifiers e.g. the following transformations are legal d1.d2.d3.gargoylesoftware.com may be transformed to itself or: d2.d3.gargoylesoftware.com d3.gargoylesoftware.com gargoylesoftware.com transformation to: com will fail

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.

Parameters:
newDomain - the new domain to set

getScripts

public Object getScripts()
Returns the value of the JavaScript attribute scripts.

Returns:
the value of the JavaScript attribute scripts

getSelection_js

public Selection getSelection_js()
Returns the value of the JavaScript attribute selection.

Returns:
the value of the JavaScript attribute selection

getFrames

public Object getFrames()
Returns the value of the frames property.

Returns:
the live collection of frames contained by this document
See Also:
MSDN documentation

getStyleSheets

public 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.

Returns:
styleSheet collection

createEvent

public Event createEvent(String eventType)
                  throws DOMException
Implementation of the DocumentEvent interface's DocumentEvent method. The method creates an uninitialized event of the specified type.

Parameters:
eventType - the event type to create
Returns:
an event object for the specified type
Throws:
DOMException - if the event type is not supported (will have a type of DOMException.NOT_SUPPORTED_ERR)
See Also:
DocumentEvent

createEventObject

public Event createEventObject()
Implementation of the createEventObject method supported by Internet Explorer. This method returns an uninitialized event object. It is up to the caller of the method to initialize the properties of the event.

Returns:
an uninitialized event object
See Also:
MSDN Documentation

elementFromPoint

public Object elementFromPoint(int x,
                               int y)
Returns the element for the specified x coordinate and the specified y coordinate. The current implementation always returns the <body> element.

Parameters:
x - the x offset, in pixels
y - the y offset, in pixels
Returns:
the element for the specified x coordinate and the specified y coordinate

createRange

public Range createRange()
Creates and returns a new range.

Returns:
a new range
See Also:
XUL Planet

createTreeWalker

public Object createTreeWalker(Node root,
                               double whatToShow,
                               net.sourceforge.htmlunit.corejs.javascript.Scriptable filter,
                               boolean expandEntityReferences)
                        throws DOMException
Creates and returns a new TreeWalker. The following JavaScript parameters are passed into this method:

Parameters:
root - the node which will serve as the root for the TreeWalker
whatToShow - specifies which node types may appear in the logical view of the tree presented
filter - the NodeFilter to be used with this TreeWalker, or null to indicate no filter
expandEntityReferences - If false, the contents of EntityReference nodes are not presented in the logical view
Returns:
a new TreeWalker
Throws:
DOMException - on attempt to create a TreeWalker with a root that is null
See Also:
DOM-Level-2-Traversal-Range

queryCommandSupported

public boolean queryCommandSupported(String cmd)
Indicates if the command is supported.

Parameters:
cmd - the command identifier
Returns:
true> if the command is supported
See Also:
MSDN documentation

queryCommandEnabled

public boolean queryCommandEnabled(String cmd)
Indicates if the command can be successfully executed using execCommand, given the current state of the document.

Parameters:
cmd - the command identifier
Returns:
true if the command can be successfully executed

execCommand

public boolean execCommand(String cmd,
                           boolean userInterface,
                           Object value)
Executes a command.

Parameters:
cmd - the command identifier
userInterface - display a user interface if the command supports one
value - the string, number, or other value to assign (possible values depend on the command)
Returns:
true if the command was successful, false otherwise
See Also:
MSDN documentation

getActiveElement

public Object getActiveElement()
Returns the value of the "activeElement" property.

Returns:
the value of the "activeElement" property
See Also:
MSDN documentation

setActiveElement

public void setActiveElement(HTMLElement element)
Sets the specified element as the document's active element.

Parameters:
element - the new active element for this document
See Also:
HTMLElement.setActive()

getDoctype

public SimpleScriptable getDoctype()
Gets the JavaScript property "doctype" for the document.

Overrides:
getDoctype in class Document
Returns:
the DocumentType of the document

dispatchEvent

public boolean dispatchEvent(Event event)
Dispatches an event into the event system (standards-conformant browsers only). See the Gecko DOM reference for more information.

Parameters:
event - the event to be dispatched
Returns:
false if at least one of the event handlers which handled the event called preventDefault; true otherwise

querySelectorAll

public StaticNodeList querySelectorAll(String selectors)
Retrieves all element nodes from descendants of the starting element node that match any selector within the supplied selector strings. The NodeList object returned by the querySelectorAll() method must be static, not live.

Parameters:
selectors - the selectors
Returns:
the static node list

querySelector

public Node querySelector(String selectors)
Returns the first element within the document that matches the specified group of selectors.

Parameters:
selectors - the selectors
Returns:
null if no matches are found; otherwise, it returns the first matching element

get

public Object get(String name,
                  net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
Gets a named property from the object. Normally HtmlUnit objects don't need to overwrite this method as properties are defined on the prototypes from the XML configuration. In some cases where "content" of object has priority compared to the properties consider using utility SimpleScriptable.getWithPreemption(String). For fallback case just implement ScriptableWithFallbackGetter.

Specified by:
get in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
Overrides:
get in class SimpleScriptable

clear

public void clear()
Does... nothing.

See Also:
Mozilla doc

makeScriptableFor

public SimpleScriptable makeScriptableFor(DomNode domNode)
Builds a new the JavaScript object that corresponds to the specified object.

Overrides:
makeScriptableFor in class SimpleScriptable
Parameters:
domNode - the DOM node for which a JS object should be created
Returns:
the JavaScript object

setHead

public void setHead(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject head)
Sets the head.

Parameters:
head - the head

getSelection

public Selection getSelection()
Returns the current selection.

Returns:
the current selection


Copyright © 2002-2012 Gargoyle Software Inc.. All Rights Reserved.