com.gargoylesoftware.htmlunit.html
Class HtmlScript

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.html.DomNode
      extended by com.gargoylesoftware.htmlunit.html.DomNamespaceNode
          extended by com.gargoylesoftware.htmlunit.html.DomElement
              extended by com.gargoylesoftware.htmlunit.html.HtmlElement
                  extended by com.gargoylesoftware.htmlunit.html.HtmlScript
All Implemented Interfaces:
Serializable, Cloneable

public class HtmlScript
extends HtmlElement

Wrapper for the html element "script".
When a script tag references an external script (with attribute src) it gets executed when the node is added to the DOM tree. When the script code is nested, it gets executed when the text node containing the script is added to the HtmlScript.
The ScriptFilter feature of NekoHtml can't be used because it doesn't allow immediate access to the DOM (i.e. document.write("<span id='mySpan'/>"); document.getElementById("mySpan").tagName; can't work with a filter).

Version:
$Revision: 2163 $
Author:
Mike Bowler, Christian Sell, Marc Guillemot, David K. Taylor, Ahmed Ashour, Daniel Gredler
See Also:
DOM Level 1, DOM Level 2, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
HtmlElement.ChildElementsIterator, HtmlElement.MapEntryWrappingIterator
 
Nested classes/interfaces inherited from class com.gargoylesoftware.htmlunit.html.DomNode
DomNode.ChildIterator, DomNode.DescendantElementsIterator
 
Field Summary
static String TAG_NAME
          The HTML tag represented by this element.
 
Fields inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
ATTRIBUTE_NOT_DEFINED, ATTRIBUTE_VALUE_EMPTY, TAB_INDEX_OUT_OF_BOUNDS
 
Fields inherited from class com.gargoylesoftware.htmlunit.html.DomNode
ATTRIBUTE_NODE, COMMENT_NODE, DOCUMENT_NODE, ELEMENT_NODE, PROPERTY_ELEMENT, READY_STATE_COMPLETE, READY_STATE_INTERACTIVE, READY_STATE_LOADED, READY_STATE_LOADING, READY_STATE_UNINITIALIZED, TEXT_NODE
 
Constructor Summary
HtmlScript(HtmlPage page, Map attributes)
          Deprecated. You should not directly construct HtmlScript.
 
Method Summary
 DomNode appendDomChild(DomNode node)
          Executes the content as a script if said content is a text node.
 String asText()
          Returns a text representation of this element that represents what would be visible to the user if this page was shown in a web browser.
 String getCharsetAttribute()
          Return the value of the attribute "charset".
 String getDeferAttribute()
          Return the value of the attribute "defer".
 String getEventAttribute()
          Return the value of the attribute "event".
 String getHtmlForAttribute()
          Return the value of the attribute "for".
 String getLanguageAttribute()
          Return the value of the attribute "language".
 String getSrcAttribute()
          Return the value of the attribute "src".
 String getTypeAttribute()
          Return the value of the attribute "type".
protected  boolean isEmptyXmlTagExpanded()
          Indicates if a node without children should be written in expanded form as xml (i.e.
protected  void onAddedToPage()
          Executes the onreadystatechange handler when simulating IE, as well as executing the script itself, if necessary.
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
addHtmlAttributeChangeListener, appendChildIfNoneExists, assertNotEmpty, blur, cloneDomNode, cloneNode, fireEvent, fireEvent, fireHtmlAttributeAdded, fireHtmlAttributeRemoved, fireHtmlAttributeReplaced, focus, getAttribute, getAttributeEntriesIterator, getAttributeNS, getAttributeValue, getChildElementsIterator, getEnclosingElement, getEnclosingForm, getEnclosingFormOrDie, getEventHandler, getHtmlElementById, getHtmlElementsByAttribute, getHtmlElementsByTagName, getHtmlElementsByTagNames, getId, getNodeName, getNodeType, getOneHtmlElementByAttribute, getTabIndex, getTagName, hasAttribute, hasAttributeNS, hasAttributes, hasHtmlElementWithId, isAttributeDefined, isSubmittableByEnter, keyDown, keyDown, mouseDown, mouseDown, mouseMove, mouseMove, mouseOut, mouseOut, mouseOver, mouseOver, mouseUp, mouseUp, notImplemented, preventDefault, printOpeningTagContentAsXml, printXml, removeAttribute, removeAttributeNS, removeChild, removeEventHandler, removeHtmlAttributeChangeListener, rightClick, rightClick, setAttribute, setAttributeNS, setAttributeValue, setAttributeValue, setEventHandler, setEventHandler, setId, toString, type, type, type, type
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.DomNamespaceNode
getLocalName, getNamespaceURI, getPrefix, getQualifiedName, setPrefix
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.DomNode
addDomChangeListener, addPropertyChangeListener, appendChild, asXml, fireNodeAdded, fireNodeDeleted, firePropertyChange, getAllHtmlChildElements, getByXPath, getChildIterator, getChildrenAsText, getEndColumnNumber, getEndLineNumber, getFirstByXPath, getFirstChild, getFirstDomChild, getLastChild, getLastDomChild, getLog, getNativePage, getNextDomSibling, getNextSibling, getNodeValue, getPage, getParentDomNode, getParentNode, getPreviousDomSibling, getPreviousSibling, getReadyState, getScriptObject, getStartColumnNumber, getStartLineNumber, insertBefore, isAncestorOf, isRenderedVisible, isTrimmedText, notifyIncorrectness, onAllChildrenAddedToPage, printChildrenAsXml, reduceWhitespace, remove, removeAllChildren, removeDomChangeListener, removePropertyChangeListener, replace, setNextSibling, setNodeValue, setParentNode, setPreviousSibling, setReadyState, setScriptObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TAG_NAME

public static final String TAG_NAME
The HTML tag represented by this element.

See Also:
Constant Field Values
Constructor Detail

HtmlScript

public HtmlScript(HtmlPage page,
                  Map attributes)
Deprecated. You should not directly construct HtmlScript.

Create an instance of HtmlScript

Parameters:
page - The HtmlPage that contains this element.
attributes - the initial attributes
Method Detail

getCharsetAttribute

public final String getCharsetAttribute()
Return the value of the attribute "charset". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "charset" or an empty string if that attribute isn't defined.

getTypeAttribute

public final String getTypeAttribute()
Return the value of the attribute "type". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "type" or an empty string if that attribute isn't defined.

getLanguageAttribute

public final String getLanguageAttribute()
Return the value of the attribute "language". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "language" or an empty string if that attribute isn't defined.

getSrcAttribute

public final String getSrcAttribute()
Return the value of the attribute "src". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "src" or an empty string if that attribute isn't defined.

getEventAttribute

public final String getEventAttribute()
Return the value of the attribute "event".

Returns:
The value of the attribute "event"

getHtmlForAttribute

public final String getHtmlForAttribute()
Return the value of the attribute "for".

Returns:
The value of the attribute "for"

getDeferAttribute

public final String getDeferAttribute()
Return the value of the attribute "defer". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "defer" or an empty string if that attribute isn't defined.

appendDomChild

public DomNode appendDomChild(DomNode node)
Executes the content as a script if said content is a text node. append a child node to the end of the current list

Overrides:
appendDomChild in class DomNode
Parameters:
node - the node to append
Returns:
the node added

onAddedToPage

protected void onAddedToPage()
Executes the onreadystatechange handler when simulating IE, as well as executing the script itself, if necessary. Lifecycle method invoked whenever a node is added to a page. Intended to be overridden by nodes which need to perform custom logic when they are added to a page. This method is recursive, so if you override it, please be sure to call super.onAddedToPage().

Overrides:
onAddedToPage in class DomNode

asText

public String asText()
Description copied from class: DomNode
Returns a text representation of this element that represents what would be visible to the user if this page was shown in a web browser. For example, a single-selection select element would return the currently selected value as text.

Overrides:
asText in class DomNode
Returns:
an empty string as the content of script is not visible by itself
See Also:
HtmlInput.asText()

isEmptyXmlTagExpanded

protected boolean isEmptyXmlTagExpanded()
Indicates if a node without children should be written in expanded form as xml (i.e. with closing tag rather than with "/>")

Overrides:
isEmptyXmlTagExpanded in class HtmlElement
Returns:
true to make generated xml readable as html


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