Package org.pepstock.charba.client.dom
Class BaseDocument
- java.lang.Object
-
- org.pepstock.charba.client.dom.BaseEventTarget
-
- org.pepstock.charba.client.dom.BaseNode
-
- org.pepstock.charba.client.dom.BaseDocument
-
- Direct Known Subclasses:
BaseHtmlDocument
@JsType(isNative=true, name="Document", namespace="<global>") public class BaseDocument extends BaseNode
Represents any web page loaded in the browser and serves as an entry point in the web page's content, which is the DOM tree.
It provides functionality globally to the document, like how to obtain the page's URL and create new elements in the document.- Author:
- Andrea "Stock" Stocchero
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.pepstock.charba.client.dom.BaseEventTarget
BaseEventTarget.EventListenerCallback
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends BaseHtmlElement>
TcreateElement(String tagName)
Creates the HTML element specified by tag name.TextNode
createTextNode(String data)
Creates a new text node which can be used to escape HTML characters.double
getChildElementCount()
Returns the number of children of this parent node which are elements.BaseElement
getDocumentElement()
Returns the element that is a direct child of the document.
This is normally the object representing the document's <html< element.BaseElement
getElementById(String id)
Returns an element object representing the element whose id property matches the specified string.NodeList<BaseElement>
getElementsByTagName(String tagName)
Returns an list of elements with the given tag name.
The complete document is searched, including the root node.BaseElement
getFirstElementChild()
Returns the first node which is both a child of this parent node and is also an element, ornull
if there is none.Head
getHead()
Returns the <head> element of the current document.BaseElement
getLastElementChild()
Returns the last node which is both a child of this parent node and is an element, ornull
if there is none.BaseElement
getScrollingElement()
Returns a reference to the element that scrolls the document.-
Methods inherited from class org.pepstock.charba.client.dom.BaseNode
appendChild, cloneNode, getChildNodes, getFirstChild, getLastChild, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPreviousSibling, getTextContent, hasChildNodes, insertBefore, removeAllChildren, removeChild, setNodeValue, setTextContent
-
Methods inherited from class org.pepstock.charba.client.dom.BaseEventTarget
addEventListener, addEventListener, dispatchEvent, dispatchEvent, removeEventListener, removeEventListener
-
-
-
-
Method Detail
-
getChildElementCount
@JsProperty public final double getChildElementCount()
Returns the number of children of this parent node which are elements.- Returns:
- the number of children of this parent node which are elements
-
getDocumentElement
@JsProperty public final BaseElement getDocumentElement()
Returns the element that is a direct child of the document.
This is normally the object representing the document's <html< element.- Returns:
- the element that is a direct child of the document
-
getFirstElementChild
@JsProperty public final BaseElement getFirstElementChild()
Returns the first node which is both a child of this parent node and is also an element, ornull
if there is none.- Returns:
- the first node which is both a child of this parent node and is also an element
-
getHead
@JsProperty public final Head getHead()
Returns the <head> element of the current document.- Returns:
- the <head> element of the current document
-
getLastElementChild
@JsProperty public final BaseElement getLastElementChild()
Returns the last node which is both a child of this parent node and is an element, ornull
if there is none.- Returns:
- the last node which is both a child of this parent node and is an element
-
getScrollingElement
@JsProperty public final BaseElement getScrollingElement()
Returns a reference to the element that scrolls the document.- Returns:
- a reference to the element that scrolls the document
-
createElement
@JsMethod public final <T extends BaseHtmlElement> T createElement(String tagName)
Creates the HTML element specified by tag name.- Type Parameters:
T
- type of HTML element to create- Parameters:
tagName
- tag name of the element to create- Returns:
- the HTML element specified by tag name
-
createTextNode
@JsMethod public final TextNode createTextNode(String data)
Creates a new text node which can be used to escape HTML characters.- Parameters:
data
- the string which is containing the data to be put in the text node- Returns:
- a new text node which can be used to escape HTML characters
-
getElementById
@JsMethod public final BaseElement getElementById(String id)
Returns an element object representing the element whose id property matches the specified string.- Parameters:
id
- the id of the element to locate.
The id is case-sensitive string which is unique within the document; only one element may have any given ID.- Returns:
- an element object representing the element whose id property matches the specified string
-
getElementsByTagName
@JsMethod public final NodeList<BaseElement> getElementsByTagName(String tagName)
Returns an list of elements with the given tag name.
The complete document is searched, including the root node.- Parameters:
tagName
- tag name of the element to search- Returns:
- an list of elements with the given tag name
-
-