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

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.Element
                      extended by com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement
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
Direct Known Subclasses:
FormChild, HTMLAnchorElement, HTMLAppletElement, HTMLAreaElement, HTMLBaseElement, HTMLBaseFontElement, HTMLBodyElement, HTMLBRElement, HTMLCanvasElement, HTMLDelElement, HTMLDivElement, HTMLEmbedElement, HTMLFontElement, HTMLFormElement, HTMLFrameElement, HTMLFrameSetElement, HTMLHeadElement, HTMLHeadingElement, HTMLHRElement, HTMLHtmlElement, HTMLIFrameElement, HTMLImageElement, HTMLInsElement, HTMLIsIndexElement, HTMLLIElement, HTMLLinkElement, HTMLListElement, HTMLMapElement, HTMLMediaElement, HTMLMetaElement, HTMLOptGroupElement, HTMLParagraphElement, HTMLParamElement, HTMLPreElement, HTMLProgressElement, HTMLQuoteElement, HTMLScriptElement, HTMLSourceElement, HTMLSpacerElement, HTMLSpanElement, HTMLStyleElement, HTMLTableCaptionElement, HTMLTableComponent, HTMLTitleElement, HTMLUnknownElement, HTMLWBRElement, RowContainer

public class HTMLElement
extends Element
implements ScriptableWithFallbackGetter

The JavaScript object "HTMLElement" which is the base class for all HTML objects. This will typically wrap an instance of HtmlElement.

Version:
$Revision: 7668 $
Author:
Mike Bowler, David K. Taylor, Barnaby Court, Christian Sell, Chris Erskine, David D. Kilzer, Daniel Gredler, Marc Guillemot, Hans Donner, Bruce Faulkner, Ahmed Ashour, Sudhan Moghe, Ronald Brill
See Also:
Serialized Form

Nested Class Summary
static class HTMLElement.ProxyDomNode
          ProxyDomNode.
 
Field Summary
static int BEHAVIOR_ID_CLIENT_CAPS
          BEHAVIOR_ID_CLIENT_CAPS.
static int BEHAVIOR_ID_DOWNLOAD
          BEHAVIOR_ID_DOWNLOAD.
static int BEHAVIOR_ID_HOMEPAGE
          BEHAVIOR_ID_HOMEPAGE.
 
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
HTMLElement()
           
 
Method Summary
 int addBehavior(String behavior)
          Adds the specified behavior to this HTML element.
 void addComponentRequest(String id, String idType, String minVersion)
          Adds the specified component to the queue of components to be installed.
 void blur()
          Remove focus from this element.
 void clearAttributes()
          An IE-only method which clears all custom attributes.
 void clearComponentRequest()
          Clears the component install queue of all component requests.
 void click()
          Click this element.
 int compareVersions(String v1, String v2)
          Compares the two specified version numbers.
 boolean contains(HTMLElement element)
          Checks whether the given element is contained within this object.
protected  void createEventHandler(String eventName, String attrValue)
          Create the event handler function from the attribute value.
 Object createTextRange()
          Creates a new TextRange object for this element.
 boolean dispatchEvent(Event event)
          Dispatches an event into the event system (standards-conformant browsers only).
 boolean doComponentRequest()
          Downloads all the components queued via addComponentRequest(String, String, String).
 void doScroll(String scrollAction)
          Simulates a click on a scrollbar component (IE only).
protected  String fixAttributeName(String attributeName)
          For IE, foo.getAttribute(x) uses same names as foo.x.
 void focus()
          Sets the focus to this element.
 Object get(String name, net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
          Gets a named property from the object.
 String getAccessKey()
          Returns the "accessKey" property.
protected  String getAlign(boolean returnInvalidValues)
          Returns the value of the "align" property.
 HTMLCollection getAll()
          Returns the value of the "all" property.
 Object getAttribute(String attributeName, Integer flags)
          Returns the value of the specified attribute.
 Object getAttributeNode(String attributeName)
          Gets the attribute node for the specified attribute.
 Object getAttributeNodeNS(String namespaceURI, String localName)
          Returns the specified attribute.
 int getAvailHeight()
          Returns the screen's available height.
 int getAvailWidth()
          Returns the screen's available width.
 ClientRect getBoundingClientRect()
          Retrieves an object that specifies the bounds of a collection of TextRectangle objects.
 BoxObject getBoxObject()
          Returns the BoxObject for this element.
 int getBufferDepth()
          Returns the screen's buffer depth.
protected  String getCh()
          Returns the value of the "ch" property.
 HTMLCollection getChildren()
          Gets the children of the current node.
protected  String getChOff()
          Returns the value of the "chOff" property.
 DOMTokenList getClassList()
          Gets the token list of class attribute.
 Object getClassName_js()
          Returns the class defined for this element.
 int getClientHeight()
          Returns "clientHeight" attribute.
 int getClientLeft()
          Returns "clientLeft" attribute.
 Object getClientRects()
          Retrieves a collection of rectangles that describes the layout of the contents of an object or range within the client.
 int getClientTop()
          Returns "clientTop" attribute.
 int getClientWidth()
          Returns "clientWidth" attribute.
 int getColorDepth()
          Returns the screen's color depth.
 String getComponentVersion(String id, String idType)
          Returns the version of the specified component.
 String getConnectionType()
          Returns the connection type being used.
 boolean getCookieEnabled()
          Returns true if cookies are enabled.
 String getCpuClass()
          Returns the type of CPU used.
 ComputedCSSStyleDeclaration getCurrentStyle()
          Returns the current (calculated) style object for this element.
 String getDir()
          Returns the "dir" property.
 boolean getDisabled()
          Returns true if this element is disabled.
 DocumentProxy getDocument()
          Returns the document.
 HtmlElement getDomNodeOrDie()
          Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.
 HtmlElement getDomNodeOrNull()
          Returns the DOM node that corresponds to this JavaScript object or null if a node hasn't been set.
 HTMLCollection getElementsByClassName(String className)
          Returns all the descendant elements with the specified class.
 Object getFilters()
          Gets the filters.
 int getHeight()
          Returns the screen's height.
 String getId()
          Returns the element ID.
 String getInnerHTML()
          Gets the innerHTML attribute.
 String getInnerText()
          Gets the innerText attribute.
 boolean getJavaEnabled()
          Returns true if Java is enabled.
 String getLang()
          Returns the "lang" property.
 String getLanguage()
          Returns the "language" property.
 String getLocalName()
          Returns the local name of this element.
 String getNamespaceURI()
          Returns The URI that identifies an XML namespace.
 String getNodeName()
          Gets the JavaScript property "nodeName" for the current node.
 int getOffsetHeight()
          Returns this element's offsetHeight, which is the element height plus the element's padding plus the element's border.
 int getOffsetLeft()
          Returns this element's offsetLeft, which is the calculated left position of this element relative to the offsetParent.
 Object getOffsetParent_js()
          Returns this element's offsetParent.
 int getOffsetTop()
          Returns this element's offsetTop, which is the calculated top position of this element relative to the offsetParent.
 int getOffsetWidth()
          Returns this element's offsetWidth, which is the element width plus the element's padding plus the element's border.
 String getOuterHTML()
          Gets the outerHTML of the node.
 Element getParentElement()
          Gets the first ancestor instance of Element.
 HTMLElement getParentHTMLElement()
          Gets the first ancestor instance of HTMLElement.
 String getPlatform()
          Returns the platform used.
 int getPosX()
          Returns this element's X position.
 int getPosY()
          Returns this element's Y position.
 String getPrefix()
          Returns the namespace prefix.
 CSSStyleDeclaration getRuntimeStyle()
          Returns the runtime style object for this element.
 String getScopeName()
          Gets the namespace defined for the element.
 int getScrollHeight()
          Gets the scrollHeight for this element.
 int getScrollLeft()
          Gets the scrollLeft value for this element.
 int getScrollTop()
          Gets the scrollTop value for this element.
 int getScrollWidth()
          Gets the scrollWidth for this element.
 boolean getSpellcheck()
          Returns the "spellcheck" property.
 CSSStyleDeclaration getStyle()
          Returns the style object for this element.
 String getSystemLanguage()
          Returns the system language.
 int getTabIndex()
          Returns the value of the tabIndex attribute.
 String getTagName()
          Returns the tag name of this element.
 String getTagUrn()
          Gets the Uniform Resource Name (URN) specified in the namespace declaration.
 String getTitle()
          Returns the element title.
 String getUniqueID()
          Retrieves an auto-generated, unique identifier for the object.
 String getUserLanguage()
          Returns the user language.
protected  String getVAlign(String[] valid, String defaultValue)
          Returns the value of the "vAlign" property.
 int getWidth()
          Returns the screen's width.
protected  String getWidthOrHeight(String attributeName, Boolean returnNegativeValues)
          Returns the value of the specified attribute (width or height).
 Object getWithFallback(String name)
          Looks at attributes with the given name.
 boolean hasAttribute(String name)
          Returns true when an attribute with a given name is specified on this element or has a default value.
 Object insertAdjacentElement(String where, Object object)
          Inserts the given element into the element at the location.
 void insertAdjacentHTML(String where, String text)
          Inserts the given HTML text into the element at the location.
protected  boolean isAncestorOfEventTarget(MouseEvent event)
          Returns true if this element's node is an ancestor of the specified event's target node.
protected  boolean isAttributeName(String name)
          Indicates if this is the name of a well defined attribute that can be access as property.
 boolean isComponentInstalled(String id, String idType, String minVersion)
          Returns true if the specified component is installed.
 boolean isHomePage(String url)
          Returns true if the specified URL is the web client's current homepage and the document calling the method is on the same domain as the user's homepage.
 void mergeAttributes(HTMLElement source, Object preserveIdentity)
          An IE-only method which copies all custom attributes from the specified source element to this element.
 void navigateHomePage()
          Causes the web client to navigate to the current home page.
static void parseHtmlSnippet(DomNode target, boolean append, String source)
          Parses the specified HTML source code, appending the resultant content at the specified target location.
 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.
protected  org.xml.sax.helpers.AttributesImpl readAttributes(HtmlElement element)
          Gets the attributes of the element in the form of a Attributes.
 void removeAttributeNode(Attr attribute)
          Removes the specified attribute.
 void removeBehavior(int id)
          Removes the behavior corresponding to the specified identifier from this element.
 boolean removeExpression(String propertyName)
          Removes the expression from the specified property.
 HTMLElement removeNode(boolean removeChildren)
          Removes this object from the document hierarchy.
 void scrollIntoView()
          Implement the scrollIntoView() JavaScript function but don't actually do anything.
 void setAccessKey(String accessKey)
          Sets the "accessKey" property.
 void setActive()
          Sets the object as active without setting focus to the object.
protected  void setAlign(String align, boolean ignoreIfNoError)
          Sets the value of the "align" property.
 void setAttribute(String name, String value)
          Sets an attribute.
 Attr setAttributeNode(Attr newAtt)
          Sets the attribute node for the specified attribute.
protected  void setCh(String ch)
          Sets the value of the "ch" property.
protected  void setChOff(String chOff)
          Sets the value of the "chOff" property.
 void setClassName(String className)
          Sets the class attribute for this element.
protected  void setColorAttribute(String name, String value)
          Sets the specified color attribute to the specified value.
 void setDir(String dir)
          Sets the "dir" property.
 void setDisabled(boolean disabled)
          Sets whether or not to disable this element.
 void setDomNode(DomNode domNode)
          Sets the DOM node that corresponds to this JavaScript object.
 void setExpression(String propertyName, String expression, String language)
          Sets an expression for the specified HTMLElement.
 void setHomePage(String url)
          Sets the web client's current homepage.
 void setId(String newId)
          Sets the identifier this element.
 void setInnerHTML(Object value)
          Replace all children elements of this element with the supplied value.
 void setInnerText(String value)
          Replace all children elements of this element with the supplied value.
 void setLang(String lang)
          Sets the "lang" property.
 void setLanguage(String language)
          Sets the "language" property.
 void setOuterHTML(String value)
          Replace all children elements of this element with the supplied value.
 void setScrollLeft(int scroll)
          Sets the scrollLeft value for this element.
 void setScrollTop(int scroll)
          Sets the scrollTop value for this element.
 void setSpellcheck(boolean spellcheck)
          Sets the "spellcheck" property.
 void setTabIndex(int tabIndex)
          Sets the "tabIndex" property.
 void setTagUrn(String tagUrn)
          Sets the Uniform Resource Name (URN) specified in the namespace declaration.
 void setTextContent(Object value)
          Replace all children elements of this element with the supplied value.
 void setTitle(String newTitle)
          Sets the title of this element.
protected  void setVAlign(Object vAlign, String[] valid)
          Sets the value of the "vAlign" property.
protected  void setWidthOrHeight(String attributeName, String value, Boolean allowNegativeValues)
          Sets the value of the specified attribute (width or height).
 void startDownload(String uri, net.sourceforge.htmlunit.corejs.javascript.Function callback)
          Implementation of the IE behavior #default#download.
 String toString()
          
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.host.Element
createAttributesObject, getAttributeNS, getAttributes, getBaseURI, getChildElementCount, getElementsByTagName, getElementsByTagNameNS, getFirstElementChild, getLastElementChild, getNextElementSibling, getPreviousElementSibling, getText, hasAttributeNS, removeAttribute, removeAttributeNS, selectNodes, selectSingleNode, setAttributeNS, setDefaults
 
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, appendChild, attachEvent, cloneNode, compareDocumentPosition, detachEvent, executeEvent, fireEvent, fireEvent, getChildNodes, getEventHandler, getEventHandlerProp, getFirstChild, getJavaScriptNode, getLastChild, getNextSibling, getNodeType, getNodeValue, getOwnerDocument, getParent, getParentNode, getPreviousSibling, getTextContent, getXml, hasChildNodes, hasEventHandlers, insertBefore, insertBeforeImpl, isSameNode, normalize, removeChild, removeEventListener, replaceChild, setEventHandler, setEventHandlerProp, setNodeValue
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
clone, defineFunctionProperties, defineProperty, equivalentValues, getBrowserVersion, getClassName, getDefaultValue, getPrototype, getScriptableFor, getStartingScope, getTransformerScriptableFor, getWindow, getWindow, getWithPreemption, hasInstance, initParentScope, isReadOnlySettable, makeScriptableFor, 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, 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

BEHAVIOR_ID_CLIENT_CAPS

public static final int BEHAVIOR_ID_CLIENT_CAPS
BEHAVIOR_ID_CLIENT_CAPS.

See Also:
Constant Field Values

BEHAVIOR_ID_HOMEPAGE

public static final int BEHAVIOR_ID_HOMEPAGE
BEHAVIOR_ID_HOMEPAGE.

See Also:
Constant Field Values

BEHAVIOR_ID_DOWNLOAD

public static final int BEHAVIOR_ID_DOWNLOAD
BEHAVIOR_ID_DOWNLOAD.

See Also:
Constant Field Values
Constructor Detail

HTMLElement

public HTMLElement()
Method Detail

getAll

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

Returns:
the value of the "all" property

setDomNode

public void setDomNode(DomNode domNode)
Sets the DOM node that corresponds to this JavaScript object.

Overrides:
setDomNode in class Node
Parameters:
domNode - the DOM node

createEventHandler

protected void createEventHandler(String eventName,
                                  String attrValue)
Create the event handler function from the attribute value.

Parameters:
eventName - the event name (ex: "onclick")
attrValue - the attribute value

getId

public String getId()
Returns the element ID.

Returns:
the ID of this element

setId

public void setId(String newId)
Sets the identifier this element.

Parameters:
newId - the new identifier of this element

getTitle

public String getTitle()
Returns the element title.

Returns:
the ID of this element

setTitle

public void setTitle(String newTitle)
Sets the title of this element.

Parameters:
newTitle - the new identifier of this element

getDisabled

public boolean getDisabled()
Returns true if this element is disabled.

Returns:
true if this element is disabled

getDocument

public DocumentProxy getDocument()
Returns the document.

Returns:
the document

setDisabled

public void setDisabled(boolean disabled)
Sets whether or not to disable this element.

Parameters:
disabled - True if this is to be disabled

getNamespaceURI

public String getNamespaceURI()
Returns The URI that identifies an XML namespace.

Overrides:
getNamespaceURI in class Node
Returns:
the URI that identifies an XML namespace

getLocalName

public String getLocalName()
Returns the local name of this element.

Overrides:
getLocalName in class Node
Returns:
the local name of this element

getWithFallback

public Object getWithFallback(String name)
Looks at attributes with the given 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

isAttributeName

protected boolean isAttributeName(String name)
Indicates if this is the name of a well defined attribute that can be access as property. Ex: for HtmlInputElement maxlength => false but maxLength => true

Parameters:
name - the name (case sensitive!)
Returns:
false if no standard attribute exists with this name

fixAttributeName

protected String fixAttributeName(String attributeName)
For IE, foo.getAttribute(x) uses same names as foo.x.

Overrides:
fixAttributeName in class Element
Parameters:
attributeName - the name
Returns:
the real name

clearAttributes

public void clearAttributes()
An IE-only method which clears all custom attributes.


mergeAttributes

public void mergeAttributes(HTMLElement source,
                            Object preserveIdentity)
An IE-only method which copies all custom attributes from the specified source element to this element.

Parameters:
source - the source element from which to copy the custom attributes
preserveIdentity - if false, the name and id attributes are not copied

getAttributeNodeNS

public Object getAttributeNodeNS(String namespaceURI,
                                 String localName)
Returns the specified attribute.

Parameters:
namespaceURI - the namespace URI
localName - the local name of the attribute to look for
Returns:
the specified attribute, null if the attribute is not defined

setAttribute

public void setAttribute(String name,
                         String value)
Sets an attribute. See also the DOM reference

Overrides:
setAttribute in class Element
Parameters:
name - Name of the attribute to set
value - Value to set the attribute to

removeAttributeNode

public void removeAttributeNode(Attr attribute)
Removes the specified attribute.

Parameters:
attribute - the attribute to remove

removeNode

public HTMLElement removeNode(boolean removeChildren)
Removes this object from the document hierarchy.

Parameters:
removeChildren - whether to remove children or no
Returns:
a reference to the object that is removed

getAttributeNode

public Object getAttributeNode(String attributeName)
Gets the attribute node for the specified attribute.

Overrides:
getAttributeNode in class Element
Parameters:
attributeName - the name of the attribute to retrieve
Returns:
the attribute node for the specified attribute

setAttributeNode

public Attr setAttributeNode(Attr newAtt)
Sets the attribute node for the specified attribute.

Parameters:
newAtt - the attribute to set
Returns:
the replaced attribute node, if any

getElementsByClassName

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

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

getClassName_js

public Object getClassName_js()
Returns the class defined for this element.

Returns:
the class name

getClientHeight

public int getClientHeight()
Returns "clientHeight" attribute.

Returns:
the "clientHeight" attribute

getClientWidth

public int getClientWidth()
Returns "clientWidth" attribute.

Returns:
the "clientWidth" attribute

setClassName

public void setClassName(String className)
Sets the class attribute for this element.

Parameters:
className - the new class name

getInnerHTML

public String getInnerHTML()
Gets the innerHTML attribute.

Returns:
the contents of this node as HTML

getInnerText

public String getInnerText()
Gets the innerText attribute.

Returns:
the contents of this node as text

getOuterHTML

public String getOuterHTML()
Gets the outerHTML of the node.

Returns:
the contents of this node as HTML
See Also:
MSDN documentation

setInnerHTML

public void setInnerHTML(Object value)
Replace all children elements of this element with the supplied value.

Parameters:
value - the new value for the contents of this node

setInnerText

public void setInnerText(String value)
Replace all children elements of this element with the supplied value.

Parameters:
value - the new value for the contents of this node

setTextContent

public void setTextContent(Object value)
Replace all children elements of this element with the supplied value.

Overrides:
setTextContent in class Node
Parameters:
value - the new value for the contents of this node

setOuterHTML

public void setOuterHTML(String value)
Replace all children elements of this element with the supplied value. Sets the outerHTML of the node.

Parameters:
value - the new value for replacing this node
See Also:
MSDN documentation

parseHtmlSnippet

public static void parseHtmlSnippet(DomNode target,
                                    boolean append,
                                    String source)
Parses the specified HTML source code, appending the resultant content at the specified target location.

Parameters:
target - the node indicating the position at which the parsed content should be placed
append - if true, append the parsed content as a child of the specified target; if false, append the parsed content as the previous sibling of the specified target
source - the HTML code extract to parse

readAttributes

protected org.xml.sax.helpers.AttributesImpl readAttributes(HtmlElement element)
Gets the attributes of the element in the form of a Attributes.

Parameters:
element - the element to read the attributes from
Returns:
the attributes

insertAdjacentHTML

public void insertAdjacentHTML(String where,
                               String text)
Inserts the given HTML text into the element at the location.

Parameters:
where - specifies where to insert the HTML text, using one of the following value: beforeBegin, afterBegin, beforeEnd, afterEnd
text - the HTML text to insert
See Also:
MSDN documentation

insertAdjacentElement

public Object insertAdjacentElement(String where,
                                    Object object)
Inserts the given element into the element at the location.

Parameters:
where - specifies where to insert the element, using one of the following value: beforeBegin, afterBegin, beforeEnd, afterEnd
object - the element to insert
Returns:
an element object
See Also:
MSDN documentation

addBehavior

public int addBehavior(String behavior)
Adds the specified behavior to this HTML element. Currently only supports the following default IE behaviors:

Parameters:
behavior - the URL of the behavior to add, or a default behavior name
Returns:
an identifier that can be user later to detach the behavior from the element

removeBehavior

public void removeBehavior(int id)
Removes the behavior corresponding to the specified identifier from this element.

Parameters:
id - the identifier for the behavior to remove

getAvailHeight

public int getAvailHeight()
Returns the screen's available height. Part of the #default#clientCaps default IE behavior implementation.

Returns:
the screen's available height

getAvailWidth

public int getAvailWidth()
Returns the screen's available width. Part of the #default#clientCaps default IE behavior implementation.

Returns:
the screen's available width

getBufferDepth

public int getBufferDepth()
Returns the screen's buffer depth. Part of the #default#clientCaps default IE behavior implementation.

Returns:
the screen's buffer depth

getBoxObject

public BoxObject getBoxObject()
Returns the BoxObject for this element.

Returns:
the BoxObject for this element

getColorDepth

public int getColorDepth()
Returns the screen's color depth. Part of the #default#clientCaps default IE behavior implementation.

Returns:
the screen's color depth

getConnectionType

public String getConnectionType()
Returns the connection type being used. Part of the #default#clientCaps default IE behavior implementation.

Returns:
the connection type being used Current implementation always return "modem"

getCookieEnabled

public boolean getCookieEnabled()
Returns true if cookies are enabled. Part of the #default#clientCaps default IE behavior implementation.

Returns:
whether or not cookies are enabled

getCpuClass

public String getCpuClass()
Returns the type of CPU used. Part of the #default#clientCaps default IE behavior implementation.

Returns:
the type of CPU used

getHeight

public int getHeight()
Returns the screen's height. Part of the #default#clientCaps default IE behavior implementation.

Returns:
the screen's height

getJavaEnabled

public boolean getJavaEnabled()
Returns true if Java is enabled. Part of the #default#clientCaps default IE behavior implementation.

Returns:
whether or not Java is enabled

getPlatform

public String getPlatform()
Returns the platform used. Part of the #default#clientCaps default IE behavior implementation.

Returns:
the platform used

getSystemLanguage

public String getSystemLanguage()
Returns the system language. Part of the #default#clientCaps default IE behavior implementation.

Returns:
the system language

getUserLanguage

public String getUserLanguage()
Returns the user language. Part of the #default#clientCaps default IE behavior implementation.

Returns:
the user language

getWidth

public int getWidth()
Returns the screen's width. Part of the #default#clientCaps default IE behavior implementation.

Returns:
the screen's width

addComponentRequest

public void addComponentRequest(String id,
                                String idType,
                                String minVersion)
Adds the specified component to the queue of components to be installed. Note that no components ever get installed, and this call is always ignored. Part of the #default#clientCaps default IE behavior implementation.

Parameters:
id - the identifier for the component to install
idType - the type of identifier specified
minVersion - the minimum version of the component to install

clearComponentRequest

public void clearComponentRequest()
Clears the component install queue of all component requests. Note that no components ever get installed, and this call is always ignored. Part of the #default#clientCaps default IE behavior implementation.


compareVersions

public int compareVersions(String v1,
                           String v2)
Compares the two specified version numbers. Part of the #default#clientCaps default IE behavior implementation.

Parameters:
v1 - the first of the two version numbers to compare
v2 - the second of the two version numbers to compare
Returns:
-1 if v1 < v2, 0 if v1 = v2, and 1 if v1 > v2

doComponentRequest

public boolean doComponentRequest()
Downloads all the components queued via addComponentRequest(String, String, String).

Returns:
true if the components are downloaded successfully Current implementation always return false

getComponentVersion

public String getComponentVersion(String id,
                                  String idType)
Returns the version of the specified component.

Parameters:
id - the identifier for the component whose version is to be returned
idType - the type of identifier specified
Returns:
the version of the specified component

isComponentInstalled

public boolean isComponentInstalled(String id,
                                    String idType,
                                    String minVersion)
Returns true if the specified component is installed.

Parameters:
id - the identifier for the component to check for
idType - the type of id specified
minVersion - the minimum version to check for
Returns:
true if the specified component is installed

startDownload

public void startDownload(String uri,
                          net.sourceforge.htmlunit.corejs.javascript.Function callback)
                   throws MalformedURLException
Implementation of the IE behavior #default#download.

Parameters:
uri - the URI of the download source
callback - the method which should be called when the download is finished
Throws:
MalformedURLException - if the URL cannot be created
See Also:
MSDN documentation

isHomePage

public boolean isHomePage(String url)
Returns true if the specified URL is the web client's current homepage and the document calling the method is on the same domain as the user's homepage. Part of the #default#homePage default IE behavior implementation.

Parameters:
url - the URL to check
Returns:
true if the specified URL is the current homepage

setHomePage

public void setHomePage(String url)
Sets the web client's current homepage. Part of the #default#homePage default IE behavior implementation.

Parameters:
url - the new homepage URL

navigateHomePage

public void navigateHomePage()
                      throws IOException
Causes the web client to navigate to the current home page. Part of the #default#homePage default IE behavior implementation.

Throws:
IOException - if loading home page fails

getOffsetHeight

public int getOffsetHeight()
Returns this element's offsetHeight, which is the element height plus the element's padding plus the element's border. This method returns a dummy value compatible with mouse event coordinates during mouse events.

Returns:
this element's offsetHeight
See Also:
MSDN Documentation, Element Dimensions

getOffsetWidth

public int getOffsetWidth()
Returns this element's offsetWidth, which is the element width plus the element's padding plus the element's border. This method returns a dummy value compatible with mouse event coordinates during mouse events.

Returns:
this element's offsetWidth
See Also:
MSDN Documentation, Element Dimensions

isAncestorOfEventTarget

protected boolean isAncestorOfEventTarget(MouseEvent event)
Returns true if this element's node is an ancestor of the specified event's target node.

Parameters:
event - the event whose target node is to be checked
Returns:
true if this element's node is an ancestor of the specified event's target node

toString

public String toString()

Overrides:
toString in class Object

getScrollTop

public int getScrollTop()
Gets the scrollTop value for this element.

Returns:
the scrollTop value for this element
See Also:
MSDN documentation

setScrollTop

public void setScrollTop(int scroll)
Sets the scrollTop value for this element.

Parameters:
scroll - the scrollTop value for this element

getScrollLeft

public int getScrollLeft()
Gets the scrollLeft value for this element.

Returns:
the scrollLeft value for this element
See Also:
MSDN documentation

setScrollLeft

public void setScrollLeft(int scroll)
Sets the scrollLeft value for this element.

Parameters:
scroll - the scrollLeft value for this element

getScrollHeight

public int getScrollHeight()
Gets the scrollHeight for this element.

Returns:
a dummy value of 10
See Also:
MSDN documentation

getScrollWidth

public int getScrollWidth()
Gets the scrollWidth for this element.

Returns:
a dummy value of 10
See Also:
MSDN documentation

getScopeName

public String getScopeName()
Gets the namespace defined for the element.

Returns:
the namespace defined for the element
See Also:
MSDN documentation

getTagUrn

public String getTagUrn()
Gets the Uniform Resource Name (URN) specified in the namespace declaration.

Returns:
the Uniform Resource Name (URN) specified in the namespace declaration
See Also:
MSDN documentation

setTagUrn

public void setTagUrn(String tagUrn)
Sets the Uniform Resource Name (URN) specified in the namespace declaration.

Parameters:
tagUrn - the Uniform Resource Name (URN) specified in the namespace declaration
See Also:
MSDN documentation

getParentHTMLElement

public HTMLElement getParentHTMLElement()
Gets the first ancestor instance of HTMLElement. It is mostly identical to Node.getParent() except that it skips XML nodes.

Returns:
the parent HTML element
See Also:
Node.getParent()

scrollIntoView

public void scrollIntoView()
Implement the scrollIntoView() JavaScript function but don't actually do anything. The requirement is just to prevent scripts that call that method from failing


getClientRects

public Object getClientRects()
Retrieves a collection of rectangles that describes the layout of the contents of an object or range within the client. Each rectangle describes a single line.

Returns:
a collection of rectangles that describes the layout of the contents

setExpression

public void setExpression(String propertyName,
                          String expression,
                          String language)
Sets an expression for the specified HTMLElement.

Parameters:
propertyName - Specifies the name of the property to which expression is added
expression - specifies any valid script statement without quotations or semicolons This string can include references to other properties on the current page. Array references are not allowed on object properties included in this script.
language - specified the language used

removeExpression

public boolean removeExpression(String propertyName)
Removes the expression from the specified property.

Parameters:
propertyName - Specifies the name of the property from which to remove an expression
Returns:
true if the expression was successfully removed

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

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

getDomNodeOrDie

public final HtmlElement getDomNodeOrDie()
Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.

Overrides:
getDomNodeOrDie in class Element
Returns:
the DOM node

getDomNodeOrNull

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

blur

public void blur()
Remove focus from this element.


createTextRange

public Object createTextRange()
Creates a new TextRange object for this element.

Returns:
a new TextRange object for this element

contains

public boolean contains(HTMLElement element)
Checks whether the given element is contained within this object.

Parameters:
element - element object that specifies the element to check
Returns:
true if the element is contained within this object

focus

public void focus()
Sets the focus to this element.


setActive

public void setActive()
Sets the object as active without setting focus to the object.

See Also:
MSDN documentation

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

getNodeName

public String getNodeName()
Gets the JavaScript property "nodeName" for the current node.

Overrides:
getNodeName in class Node
Returns:
the node name

getPrefix

public String getPrefix()
Returns the namespace prefix.

Overrides:
getPrefix in class Node
Returns:
the namespace prefix

getFilters

public Object getFilters()
Gets the filters.

Returns:
the filters
See Also:
MSDN doc

click

public void click()
           throws IOException
Click this element. This simulates the action of the user clicking with the mouse.

Throws:
IOException - if this click triggers a page load that encounters problems

getSpellcheck

public boolean getSpellcheck()
Returns the "spellcheck" property.

Returns:
the "spellcheck" property

setSpellcheck

public void setSpellcheck(boolean spellcheck)
Sets the "spellcheck" property.

Parameters:
spellcheck - the "spellcheck" property

getLang

public String getLang()
Returns the "lang" property.

Returns:
the "lang" property

setLang

public void setLang(String lang)
Sets the "lang" property.

Parameters:
lang - the "lang" property

getLanguage

public String getLanguage()
Returns the "language" property.

Returns:
the "language" property

setLanguage

public void setLanguage(String language)
Sets the "language" property.

Parameters:
language - the "language" property

getDir

public String getDir()
Returns the "dir" property.

Returns:
the "dir" property

setDir

public void setDir(String dir)
Sets the "dir" property.

Parameters:
dir - the "dir" property

getTabIndex

public int getTabIndex()
Returns the value of the tabIndex attribute.

Returns:
the value of the tabIndex attribute

setTabIndex

public void setTabIndex(int tabIndex)
Sets the "tabIndex" property.

Parameters:
tabIndex - the "tabIndex" property

doScroll

public void doScroll(String scrollAction)
Simulates a click on a scrollbar component (IE only).

Parameters:
scrollAction - the type of scroll action to simulate

getAccessKey

public String getAccessKey()
Returns the "accessKey" property.

Returns:
the "accessKey" property

setAccessKey

public void setAccessKey(String accessKey)
Sets the "accessKey" property.

Parameters:
accessKey - the "accessKey" property

getWidthOrHeight

protected String getWidthOrHeight(String attributeName,
                                  Boolean returnNegativeValues)
Returns the value of the specified attribute (width or height).

Parameters:
attributeName - the name of the attribute to return ("width" or "height")
returnNegativeValues - if true, negative values are returned; if false, this method returns an empty string in lieu of negative values; if null, this method returns 0 in lieu of negative values
Returns:
the value of the specified attribute (width or height)

setWidthOrHeight

protected void setWidthOrHeight(String attributeName,
                                String value,
                                Boolean allowNegativeValues)
Sets the value of the specified attribute (width or height).

Parameters:
attributeName - the name of the attribute to set ("width" or "height")
value - the value of the specified attribute (width or height)
allowNegativeValues - if true, negative values will be stored; if false, negative values cause an exception to be thrown; if null, negative values set the value to 0

setColorAttribute

protected void setColorAttribute(String name,
                                 String value)
Sets the specified color attribute to the specified value.

Parameters:
name - the color attribute's name
value - the color attribute's value

getAlign

protected String getAlign(boolean returnInvalidValues)
Returns the value of the "align" property.

Parameters:
returnInvalidValues - if true, this method will return any value, including technically invalid values; if false, this method will return an empty string instead of invalid values
Returns:
the value of the "align" property

setAlign

protected void setAlign(String align,
                        boolean ignoreIfNoError)
Sets the value of the "align" property.

Parameters:
align - the value of the "align" property
ignoreIfNoError - if true, the invocation will be a no-op if it does not trigger an error (i.e., it will not actually set the align attribute)

getVAlign

protected String getVAlign(String[] valid,
                           String defaultValue)
Returns the value of the "vAlign" property.

Parameters:
valid - the valid values; if null, any value is valid
defaultValue - the default value to use, if necessary
Returns:
the value of the "vAlign" property

setVAlign

protected void setVAlign(Object vAlign,
                         String[] valid)
Sets the value of the "vAlign" property.

Parameters:
vAlign - the value of the "vAlign" property
valid - the valid values; if null, any value is valid

getCh

protected String getCh()
Returns the value of the "ch" property.

Returns:
the value of the "ch" property

setCh

protected void setCh(String ch)
Sets the value of the "ch" property.

Parameters:
ch - the value of the "ch" property

getChOff

protected String getChOff()
Returns the value of the "chOff" property.

Returns:
the value of the "chOff" property

setChOff

protected void setChOff(String chOff)
Sets the value of the "chOff" property.

Parameters:
chOff - the value of the "chOff" property

getCurrentStyle

public ComputedCSSStyleDeclaration getCurrentStyle()
Returns the current (calculated) style object for this element.

Returns:
the current (calculated) style object for this element

getOffsetLeft

public int getOffsetLeft()
Returns this element's offsetLeft, which is the calculated left position of this element relative to the offsetParent.

Returns:
this element's offsetLeft
See Also:
MSDN Documentation, Element Dimensions, Reverse Engineering by Anne van Kesteren

getPosX

public int getPosX()
Returns this element's X position.

Returns:
this element's X position

getPosY

public int getPosY()
Returns this element's Y position.

Returns:
this element's Y position

getClientLeft

public int getClientLeft()
Returns "clientLeft" attribute.

Returns:
the "clientLeft" attribute

getClientTop

public int getClientTop()
Returns "clientTop" attribute.

Returns:
the "clientTop" attribute

getOffsetTop

public int getOffsetTop()
Returns this element's offsetTop, which is the calculated top position of this element relative to the offsetParent.

Returns:
this element's offsetTop
See Also:
MSDN Documentation, Element Dimensions, Reverse Engineering by Anne van Kesteren

getOffsetParent_js

public Object getOffsetParent_js()
Returns this element's offsetParent. The offsetLeft and offsetTop attributes are relative to the offsetParent.

Returns:
this element's offsetParent. This may be undefined when this node is not attached or null for body.
See Also:
MSDN Documentation, Gecko DOM Reference, Element Dimensions, Box Model, Reverse Engineering by Anne van Kesteren

getBoundingClientRect

public ClientRect getBoundingClientRect()
Retrieves an object that specifies the bounds of a collection of TextRectangle objects.

Overrides:
getBoundingClientRect in class Element
Returns:
an object that specifies the bounds of a collection of TextRectangle objects
See Also:
MSDN doc

getStyle

public CSSStyleDeclaration getStyle()
Returns the style object for this element.

Returns:
the style object for this element

getRuntimeStyle

public CSSStyleDeclaration getRuntimeStyle()
Returns the runtime style object for this element.

Returns:
the runtime style object for this element

getClassList

public DOMTokenList getClassList()
Gets the token list of class attribute.

Overrides:
getClassList in class Element
Returns:
the token list of class attribute

hasAttribute

public boolean hasAttribute(String name)
Returns true when an attribute with a given name is specified on this element or has a default value. See also the DOM reference Overridden to modify browser configurations.

Overrides:
hasAttribute in class Element
Parameters:
name - the name of the attribute to look for
Returns:
true if an attribute with the given name is specified on this element or has a default value

getAttribute

public Object getAttribute(String attributeName,
                           Integer flags)
Returns the value of the specified attribute. Overridden to modify browser configurations.

Overrides:
getAttribute in class Element
Parameters:
attributeName - attribute name
flags - IE-specific flags (see the MSDN documentation for more info)
Returns:
the value of the specified attribute, null if the attribute is not defined
See Also:
MSDN Documentation, IE Bug Documentation

getTagName

public final String getTagName()
Returns the tag name of this element. Overridden to modify browser configurations.

Overrides:
getTagName in class Element
Returns:
the tag name

getChildren

public HTMLCollection getChildren()
Gets the children of the current node. Overridden to modify browser configurations.

Overrides:
getChildren in class Element
Returns:
the child at the given position
See Also:
MSDN documentation

getParentElement

public Element getParentElement()
Gets the first ancestor instance of Element. It is mostly identical to Node.getParent() except that it skips non Element nodes. Overridden to modify browser configurations.

Overrides:
getParentElement in class Element
Returns:
the parent element
See Also:
Node.getParent()


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