java.lang.Object | |
↳ | com.google.gwt.user.client.DOM |
This class provides a set of static methods that allow you to manipulate the
browser's Document Object Model (DOM). It contains methods for manipulating
both elements
and
events
.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This method is deprecated.
replaced by
addNativePreviewHandler(Event.NativePreviewHandler)
| |||||||||||
Appends one element to another's list of children.
| |||||||||||
Clones an element.
| |||||||||||
This method is deprecated.
Use identity comparison.
| |||||||||||
Creates an HTML A element.
| |||||||||||
Creates an HTML BUTTON element.
| |||||||||||
Creates an HTML CAPTION element.
| |||||||||||
Creates an HTML COL element.
| |||||||||||
Creates an HTML COLGROUP element.
| |||||||||||
Creates an HTML DIV element.
| |||||||||||
Creates an HTML element.
| |||||||||||
Creates an HTML FIELDSET element.
| |||||||||||
Creates an HTML FORM element.
| |||||||||||
Creates an HTML IFRAME element.
| |||||||||||
Creates an HTML IMG element.
| |||||||||||
Creates an HTML INPUT type='CHECK' element.
| |||||||||||
Creates an HTML INPUT type='PASSWORD' element.
| |||||||||||
Creates an HTML INPUT type='RADIO' element.
| |||||||||||
Creates an HTML INPUT type='TEXT' element.
| |||||||||||
Creates an HTML LABEL element.
| |||||||||||
Creates an HTML LEGEND element.
| |||||||||||
Creates an HTML OPTION element.
| |||||||||||
This method is deprecated.
there is no "options" element; use
createOption()
instead
| |||||||||||
Creates an HTML SELECT element.
| |||||||||||
Creates a single-selection HTML SELECT element.
| |||||||||||
Creates an HTML SPAN element.
| |||||||||||
Creates an HTML TBODY element.
| |||||||||||
Creates an HTML TD element.
| |||||||||||
Creates an HTML TFOOT element.
| |||||||||||
Creates an HTML TH element.
| |||||||||||
Creates an HTML THEAD element.
| |||||||||||
Creates an HTML TR element.
| |||||||||||
Creates an HTML TABLE element.
| |||||||||||
Creates an HTML TEXTAREA element.
| |||||||||||
Generates a unique DOM id.
| |||||||||||
Cancels bubbling for the given event.
| |||||||||||
Gets whether the ALT key was depressed when the given event occurred.
| |||||||||||
Gets the mouse buttons that were depressed when the given event occurred.
| |||||||||||
Gets the mouse x-position within the browser window's client area.
| |||||||||||
Gets the mouse y-position within the browser window's client area.
| |||||||||||
Gets whether the CTRL key was depressed when the given event occurred.
| |||||||||||
Gets the current event that is being fired.
| |||||||||||
Gets the current target element of the given event.
| |||||||||||
Gets the element from which the mouse pointer was moved (valid for
ONMOUSEOVER and ONMOUSEOUT ). | |||||||||||
Gets the key code associated with this event.
| |||||||||||
Gets whether the META key was depressed when the given event occurred.
| |||||||||||
Gets the velocity of the mouse wheel associated with the event along the Y
axis.
| |||||||||||
This method is deprecated.
not supported in any browser but IE
| |||||||||||
Gets the mouse x-position on the user's display.
| |||||||||||
Gets the mouse y-position on the user's display.
| |||||||||||
Gets whether the shift key was depressed when the given event occurred.
| |||||||||||
Returns the element that was the actual target of the given event.
| |||||||||||
Gets the element to which the mouse pointer was moved (only valid for
ONMOUSEOUT and ONMOUSEOVER ). | |||||||||||
Gets the enumerated type of this event (as defined in
Event ). | |||||||||||
Gets the type of the given event as a string.
| |||||||||||
Prevents the browser from taking its default action for the given event.
| |||||||||||
This method is deprecated.
this method only works in IE and should not have been added to
the API
| |||||||||||
Returns a stringized version of the event.
| |||||||||||
Gets an element's absolute left coordinate in the document's coordinate
system.
| |||||||||||
Gets an element's absolute top coordinate in the document's coordinate
system.
| |||||||||||
This method is deprecated.
Use the more appropriately named
getElementProperty(Element, String) instead.
| |||||||||||
This method is deprecated.
Use the more appropriately named
getElementPropertyBoolean(Element, String) instead.
| |||||||||||
Gets the element that currently has mouse capture.
| |||||||||||
Gets an element's n-th child element.
| |||||||||||
Gets the number of child elements present in a given parent element.
| |||||||||||
Gets the index of a given child element within its parent.
| |||||||||||
Gets the named attribute from the element.
| |||||||||||
Gets the element associated with the given unique id within the entire
document.
| |||||||||||
Gets any named property from an element, as a string.
| |||||||||||
Gets any named property from an element, as a boolean.
| |||||||||||
Gets any named property from an element, as an int.
| |||||||||||
Gets the
EventListener that will receive events for the given
element. | |||||||||||
Gets the current set of events sunk by a given element.
| |||||||||||
Gets the first child element of the given element.
| |||||||||||
Gets the src attribute of an img element.
| |||||||||||
Gets an HTML representation of an element's children.
| |||||||||||
Gets the text contained within an element.
| |||||||||||
This method is deprecated.
Use the more appropriately named
getElementPropertyInt(Element, String) instead.
| |||||||||||
Gets an integer attribute on a given element's style.
| |||||||||||
Gets an element's next sibling element.
| |||||||||||
Gets an element's parent element.
| |||||||||||
Gets an attribute of the given element's style.
| |||||||||||
Inserts an element as a child of the given parent element, before another
child of that parent.
| |||||||||||
Inserts an element as a child of the given parent element.
| |||||||||||
Creates an
<option> element and inserts it as a child of
the specified <select> element. | |||||||||||
Determine whether one element is equal to, or the child of, another.
| |||||||||||
Releases mouse/touch/gesture capture on the given element.
| |||||||||||
Removes a child element from the given parent element.
| |||||||||||
Removes the named attribute from the given element.
| |||||||||||
This method is deprecated.
use
HandlerRegistration
returned from
addNativePreviewHandler(Event.NativePreviewHandler)
| |||||||||||
Scrolls the given element into view.
| |||||||||||
This method is deprecated.
Use the more appropriately named
setElementProperty(Element, String, String) instead.
| |||||||||||
This method is deprecated.
Use the more appropriately named
setElementPropertyBoolean(Element, String, boolean)
instead.
| |||||||||||
Sets mouse/touch/gesture capture on the given element.
| |||||||||||
Sets an attribute on a given element.
| |||||||||||
Sets a property on the given element.
| |||||||||||
Sets a boolean property on the given element.
| |||||||||||
Sets an int property on the given element.
| |||||||||||
Sets the
EventListener to receive events for the given element. | |||||||||||
Sets the src attribute of an img element.
| |||||||||||
Sets the HTML contained within an element.
| |||||||||||
Sets the text contained within an element.
| |||||||||||
This method is deprecated.
Use the more appropriately named
setElementPropertyInt(Element, String, int) instead.
| |||||||||||
Sets an integer attribute on the given element's style.
| |||||||||||
Sets the option text of the given select object.
| |||||||||||
Sets an attribute on the given element's style.
| |||||||||||
Sets the current set of events sunk by a given element.
| |||||||||||
Returns a stringized version of the element.
| |||||||||||
This method is deprecated.
As of GWT 1.5, replaced by
getClientHeight()
| |||||||||||
This method is deprecated.
As of GWT 1.5, replaced by
getClientWidth()
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
This method is deprecated.
replaced by
addNativePreviewHandler(Event.NativePreviewHandler)
Adds an event preview to the preview stack. As long as this preview remains on the top of the stack, it will receive all events before they are fired to their listeners. Note that the event preview will receive all events, including those received due to bubbling, whereas normal event handlers only receive explicitly sunk events.
preview | the event preview to be added to the stack. |
---|
Appends one element to another's list of children.
parent | the parent element |
---|---|
child | its new child |
Clones an element.
elem | the element to be cloned |
---|---|
deep | should children be cloned as well? |
This method is deprecated.
Use identity comparison.
Compares two elements for equality. Note that this method is now deprecated because reference identity accurately reports equality.
elem1 | the first element to be compared |
---|---|
elem2 | the second element to be compared |
true
if they are in fact the same elementCreates an HTML BUTTON element.
Creates an HTML CAPTION element.
Creates an HTML COLGROUP element.
Creates an HTML element.
tagName | the HTML tag of the element to be created |
---|
Creates an HTML FIELDSET element.
Creates an HTML IFRAME element.
Creates an HTML INPUT type='CHECK' element.
Creates an HTML INPUT type='PASSWORD' element.
Creates an HTML INPUT type='RADIO' element.
name | the name of the group with which this radio button will be associated |
---|
Creates an HTML INPUT type='TEXT' element.
Creates an HTML LABEL element.
Creates an HTML LEGEND element.
Creates an HTML OPTION element.
This method is deprecated.
there is no "options" element; use createOption()
instead
Creates an HTML OPTIONS element.
Creates an HTML SELECT element.
multiple | true if multiple selection of options is allowed |
---|
Creates a single-selection HTML SELECT element. Equivalent to
createSelect(false)
Creates an HTML TBODY element.
Creates an HTML TFOOT element.
Creates an HTML THEAD element.
Creates an HTML TABLE element.
Creates an HTML TEXTAREA element.
Generates a unique DOM id. The id is of the form "gwt-id-
Cancels bubbling for the given event. This will stop the event from being propagated to parent elements.
evt | the event on which to cancel bubbling |
---|---|
cancel | true to cancel bubbling
|
Gets whether the ALT key was depressed when the given event occurred.
evt | the event to be tested |
---|
true
if ALT was depressed when the event occurred
Gets the mouse buttons that were depressed when the given event occurred.
evt | the event to be tested |
---|
BUTTON_LEFT
,
BUTTON_MIDDLE
, and BUTTON_RIGHT
Gets the mouse x-position within the browser window's client area.
evt | the event to be tested |
---|
Gets the mouse y-position within the browser window's client area.
evt | the event to be tested |
---|
Gets whether the CTRL key was depressed when the given event occurred.
evt | the event to be tested |
---|
true
if CTRL was depressed when the event occurred
Gets the current event that is being fired. The current event is only available within the lifetime of the onBrowserEvent function. Once the onBrowserEvent method returns, the current event is reset to null.
Gets the current target element of the given event. This is the element whose listener fired last, not the element which fired the event initially.
evt | the event |
---|
Gets the element from which the mouse pointer was moved (valid for
ONMOUSEOVER
and ONMOUSEOUT
).
evt | the event to be tested |
---|
Gets the key code associated with this event.
For ONKEYPRESS
, this method returns the Unicode value of the
character generated. For ONKEYDOWN
and ONKEYUP
,
it returns the code associated with the physical key.
evt | the event to be tested |
---|
Gets whether the META key was depressed when the given event occurred.
evt | the event to be tested |
---|
true
if META was depressed when the event occurred
Gets the velocity of the mouse wheel associated with the event along the Y axis.
The velocity of the event is an artifical measurement for relative comparisons of wheel activity. It is affected by some non-browser factors, including choice of input hardware and mouse acceleration settings. The sign of the velocity measurement agrees with the screen coordinate system; negative values are towards the origin and positive values are away from the origin. Standard scrolling speed is approximately ten units per event.
evt | the event to be examined. |
---|
This method is deprecated.
not supported in any browser but IE
Gets the key-repeat state of this event. Only IE supports this attribute.
evt | the event to be tested |
---|
true
if this key event was an auto-repeatGets the mouse x-position on the user's display.
evt | the event to be tested |
---|
Gets the mouse y-position on the user's display.
evt | the event to be tested |
---|
Gets whether the shift key was depressed when the given event occurred.
evt | the event to be tested |
---|
true
if shift was depressed when the event occurred
Returns the element that was the actual target of the given event.
evt | the event to be tested |
---|
Gets the element to which the mouse pointer was moved (only valid for
ONMOUSEOUT
and ONMOUSEOVER
).
evt | the event to be tested |
---|
Gets the enumerated type of this event (as defined in Event
).
evt | the event to be tested |
---|
Gets the type of the given event as a string.
evt | the event to be tested |
---|
Prevents the browser from taking its default action for the given event.
evt | the event whose default action is to be prevented |
---|
This method is deprecated.
this method only works in IE and should not have been added to
the API
Sets the key code associated with the given keyboard event.
evt | the event whose key code is to be set |
---|---|
key | the new key code |
Returns a stringized version of the event. This string is for debugging purposes and will NOT be consistent on different browsers.
evt | the event to stringize |
---|
Gets an element's absolute left coordinate in the document's coordinate system.
elem | the element to be measured |
---|
Gets an element's absolute top coordinate in the document's coordinate system.
elem | the element to be measured |
---|
This method is deprecated.
Use the more appropriately named
getElementProperty(Element, String)
instead.
Gets any named attribute from an element, as a string.
elem | the element whose attribute is to be retrieved |
---|---|
attr | the name of the attribute |
This method is deprecated.
Use the more appropriately named
getElementPropertyBoolean(Element, String)
instead.
Gets a boolean attribute on the given element.
elem | the element whose attribute is to be set |
---|---|
attr | the name of the attribute to be set |
Gets the element that currently has mouse capture.
null
if none
exists
Gets an element's n-th child element.
parent | the element whose child is to be retrieved |
---|---|
index | the index of the child element |
Gets the number of child elements present in a given parent element.
parent | the element whose children are to be counted |
---|
Gets the index of a given child element within its parent.
parent | the parent element |
---|---|
child | the child element |
-1
if it is
not a child of the given parent
Gets the named attribute from the element.
elem | the element whose property is to be retrieved |
---|---|
attr | the name of the attribute |
Gets the element associated with the given unique id within the entire document.
id | the id whose associated element is to be retrieved |
---|
null
if none is found
Gets any named property from an element, as a string.
elem | the element whose property is to be retrieved |
---|---|
prop | the name of the property |
Gets any named property from an element, as a boolean.
elem | the element whose property is to be retrieved |
---|---|
prop | the name of the property |
Gets any named property from an element, as an int.
elem | the element whose property is to be retrieved |
---|---|
prop | the name of the property |
Gets the EventListener
that will receive events for the given
element. Only one such listener may exist for a single element.
elem | the element whose listener is to be set |
---|
Gets the current set of events sunk by a given element.
elem | the element whose events are to be retrieved |
---|
Event
)
Gets the first child element of the given element.
elem | the element whose child is to be retrieved |
---|
Gets the src attribute of an img element. This method is paired with
setImgSrc(Element, String)
so that it always returns the correct
url.
img | a non-null img whose src attribute is to be read. |
---|
Gets an HTML representation of an element's children.
elem | the element whose HTML is to be retrieved |
---|
Gets the text contained within an element. If the element has child elements, only the text between them will be retrieved.
elem | the element whose inner text is to be retrieved |
---|
This method is deprecated.
Use the more appropriately named
getElementPropertyInt(Element, String)
instead.
Gets an integer attribute on a given element.
elem | the element whose attribute is to be retrieved |
---|---|
attr | the name of the attribute to be retrieved |
Gets an integer attribute on a given element's style.
elem | the element whose style attribute is to be retrieved |
---|---|
attr | the name of the attribute to be retrieved |
Gets an element's next sibling element.
elem | the element whose sibling is to be retrieved |
---|
Gets an element's parent element.
elem | the element whose parent is to be retrieved |
---|
Gets an attribute of the given element's style.
elem | the element whose style attribute is to be retrieved |
---|---|
attr | the name of the style attribute to be retrieved |
Inserts an element as a child of the given parent element, before another child of that parent.
parent | the parent element |
---|---|
child | the child element to add to parent |
before | an existing child element of parent before which
child will be inserted
|
Inserts an element as a child of the given parent element.
parent | the parent element |
---|---|
child | the child element to add to parent |
index | the index before which the child will be inserted (any value greater than the number of existing children will cause the child to be appended) |
Creates an <option>
element and inserts it as a child of
the specified <select>
element. If the index is less
than zero, or greater than or equal to the length of the list, then the
option element will be appended to the end of the list.
selectElem | the <select> element |
---|---|
item | the text of the new item; cannot be null |
value | the value attribute for the new
<option> ; cannot be null |
index | the index at which to insert the child |
Determine whether one element is equal to, or the child of, another.
parent | the potential parent element |
---|---|
child | the potential child element |
true
if the relationship holds
Releases mouse/touch/gesture capture on the given element. Calling this method has no effect if the element does not currently have mouse/touch/gesture capture.
elem | the element to release capture |
---|
Removes a child element from the given parent element.
parent | the parent element |
---|---|
child | the child element to be removed |
Removes the named attribute from the given element.
elem | the element whose attribute is to be removed |
---|---|
attr | the name of the element to remove |
This method is deprecated.
use HandlerRegistration
returned from
addNativePreviewHandler(Event.NativePreviewHandler)
Removes an element from the preview stack. This element will no longer capture events, though any preview underneath it will begin to do so.
preview | the event preview to be removed from the stack |
---|
Scrolls the given element into view.
This method crawls up the DOM hierarchy, adjusting the scrollLeft and scrollTop properties of each scrollable element to ensure that the specified element is completely in view. It adjusts each scroll position by the minimum amount necessary.
elem | the element to be made visible |
---|
This method is deprecated.
Use the more appropriately named
setElementProperty(Element, String, String)
instead.
Sets an attribute on the given element.
elem | the element whose attribute is to be set |
---|---|
attr | the name of the attribute to be set |
value | the new attribute value |
This method is deprecated.
Use the more appropriately named
setElementPropertyBoolean(Element, String, boolean)
instead.
Sets a boolean attribute on the given element.
elem | the element whose attribute is to be set |
---|---|
attr | the name of the attribute to be set |
value | the attribute's new boolean value |
Sets mouse/touch/gesture capture on the given element. This element will
directly receive all mouse events until releaseCapture(Element)
is
called on it.
elem | the element on which to set mouse/touch/gesture capture |
---|
Sets an attribute on a given element.
elem | element whose attribute is to be set |
---|---|
attr | the name of the attribute |
value | the value to which the attribute should be set |
Sets a property on the given element.
elem | the element whose property is to be set |
---|---|
prop | the name of the property to be set |
value | the new property value |
Sets a boolean property on the given element.
elem | the element whose property is to be set |
---|---|
prop | the name of the property to be set |
value | the new property value as a boolean |
Sets an int property on the given element.
elem | the element whose property is to be set |
---|---|
prop | the name of the property to be set |
value | the new property value as an int |
Sets the EventListener
to receive events for the given element.
Only one such listener may exist for a single element.
elem | the element whose listener is to be set |
---|---|
listener | the listener to receive events
|
Sets the src attribute of an img element. This method ensures that imgs only ever have their contents requested one single time from the server.
img | a non-null img whose src attribute will be set. |
---|---|
src | a non-null url for the img |
Sets the HTML contained within an element.
elem | the element whose inner HTML is to be set |
---|---|
html | the new html |
Sets the text contained within an element. If the element already has children, they will be destroyed.
elem | the element whose inner text is to be set |
---|---|
text | the new text |
This method is deprecated.
Use the more appropriately named
setElementPropertyInt(Element, String, int)
instead.
Sets an integer attribute on the given element.
elem | the element whose attribute is to be set |
---|---|
attr | the name of the attribute to be set |
value | the attribute's new integer value |
Sets an integer attribute on the given element's style.
elem | the element whose style attribute is to be set |
---|---|
attr | the name of the style attribute to be set |
value | the style attribute's new integer value |
Sets the option text of the given select object.
select | the select object whose option text is being set |
---|---|
text | the text to set |
index | the index of the option whose text should be set |
Sets an attribute on the given element's style.
elem | the element whose style attribute is to be set |
---|---|
attr | the name of the style attribute to be set |
value | the style attribute's new value |
Sets the current set of events sunk by a given element. These events will
be fired to the nearest EventListener
specified on any of the
element's parents.
elem | the element whose events are to be retrieved |
---|---|
eventBits | a bitfield describing the events sunk on this element (its
possible values are described in Event )
|
Returns a stringized version of the element. This string is for debugging purposes and will NOT be consistent on different browsers.
elem | the element to stringize |
---|