Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 Google Inc.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
   * use this file except in compliance with the License. You may obtain a copy of
   * the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  * License for the specific language governing permissions and limitations under
  * the License.
  */
 package elemental.dom;
 
 import  elemental.dom.*;
 
 import java.util.Date;

This chapter provides a brief reference for the general methods, properties, and events available to most HTML and XML elements in the Gecko DOM.

Various W3C specifications apply to elements:

  • DOM Core Specification—describes the core interfaces shared by most DOM objects in HTML and XML documents
  • DOM HTML Specification—describes interfaces for objects in HTML and XHTML documents that build on the core specification
  • DOM Events Specification—describes events shared by most DOM objects, building on the DOM Core and Views specifications
  • Element Traversal Specification—describes the new attributes that allow traversal of elements in the DOM tree New in Firefox 3.5

The articles listed here span the above and include links to the appropriate W3C DOM specification.

While these interfaces are generally shared by most HTML and XML elements, there are more specialized interfaces for particular objects listed in the DOM HTML Specification. Note, however, that these HTML interfaces are "only for [HTML 4.01] and [XHTML 1.0] documents and are not guaranteed to work with any future version of XHTML." The HTML 5 draft does state it aims for backwards compatibility with these HTML interfaces but says of them that "some features that were formerly deprecated, poorly supported, rarely used or considered unnecessary have been removed." One can avoid the potential conflict by moving entirely to DOM XML attribute methods such as getAttribute().

Html , Head , Link , Title , Meta , Base , IsIndex , Style , Body , Form , Select , OptGroup , Option, Input , TextArea , Button , Label , FieldSet , Legend , UList , OList , DList , Directory , Menu , LI , Div , Paragraph , Heading , Quote , Pre , BR , BaseFont , Font , HR , Mod , Anchor , Image , Object , Param , Applet , Map , Area , Script , Table , TableCaption , TableCol , TableSection , TableRow , TableCell , FrameSet , Frame , IFrame

 
 public interface Element extends NodeNodeSelectorElementTraversal {
 
     static final int ALLOW_KEYBOARD_INPUT = 1;
 
  void setAccessKey(String arg);


  
The number of child nodes that are elements.
  int getChildElementCount();


  
A live nsIDOMNodeList of the current child elements.
Token list of class attribute
Gets/sets the class of the element.
  void setClassName(String arg);


  
The inner height of an element.
  int getClientHeight();


  
The width of the left border of an element.
  int getClientLeft();


  
The width of the top border of an element.
  int getClientTop();


  
The inner width of an element.
  int getClientWidth();


  
Gets/sets whether or not the element is editable.
  void setContentEditable(String arg);


  
Allows access to read and write custom data attributes on the element.
Gets/sets the directionality of the element.
  void setDir(String arg);
  boolean isDraggable();
  void setDraggable(boolean arg);


  
The first direct child element of an element, or null if the element has no child elements.
  boolean isHidden();
  void setHidden(boolean arg);


  
Gets/sets the id of the element.
  void setId(String arg);


  
Gets/sets the markup of the element's content.
  void setInnerHTML(String arg);
  void setInnerText(String arg);


  
Indicates whether or not the content of the element can be edited. Read only.
  boolean isContentEditable();


  
Gets/sets the language of an element's attributes, text, and element contents.
  void setLang(String arg);


  
The last direct child element of an element, or null if the element has no child elements.
The element immediately following the given one in the tree, or null if there's no sibling node.
The height of an element, relative to the layout.
  int getOffsetHeight();


  
The distance from this element's left border to its offsetParent's left border.
  int getOffsetLeft();


  
The element from which all offset calculations are currently computed.
The distance from this element's top border to its offsetParent's top border.
  int getOffsetTop();


  
The width of an element, relative to the layout.
  int getOffsetWidth();
  void setOnabort(EventListener arg);
  void setOnbeforepaste(EventListener arg);


  
Returns the event handling code for the blur event.
  void setOnblur(EventListener arg);


  
Returns the event handling code for the change event.
  void setOnchange(EventListener arg);


  
Returns the event handling code for the click event.
  void setOnclick(EventListener arg);


  
Returns the event handling code for the contextmenu event.
  void setOncontextmenu(EventListener arg);


  
Returns the event handling code for the copy event.
  void setOncopy(EventListener arg);


  
Returns the event handling code for the cut event.
  void setOncut(EventListener arg);


  
Returns the event handling code for the dblclick event.
  void setOndrag(EventListener arg);
  void setOndrop(EventListener arg);
  void setOnerror(EventListener arg);


  
Returns the event handling code for the focus event.
  void setOnfocus(EventListener arg);
  void setOninput(EventListener arg);
  void setOninvalid(EventListener arg);


  
Returns the event handling code for the keydown event.
  void setOnkeydown(EventListener arg);


  
Returns the event handling code for the keypress event.
  void setOnkeypress(EventListener arg);


  
Returns the event handling code for the keyup event.
  void setOnkeyup(EventListener arg);
  void setOnload(EventListener arg);


  
Returns the event handling code for the mousedown event.
  void setOnmousedown(EventListener arg);


  
Returns the event handling code for the mousemove event.
  void setOnmousemove(EventListener arg);


  
Returns the event handling code for the mouseout event.
  void setOnmouseout(EventListener arg);


  
Returns the event handling code for the mouseover event.
  void setOnmouseover(EventListener arg);


  
Returns the event handling code for the mouseup event.
  void setOnmousewheel(EventListener arg);


  
Returns the event handling code for the paste event.
  void setOnpaste(EventListener arg);
  void setOnreset(EventListener arg);


  
Returns the event handling code for the scroll event.
  void setOnscroll(EventListener arg);
  void setOnsearch(EventListener arg);
  void setOnselect(EventListener arg);
  void setOnsubmit(EventListener arg);
Gets the markup of the element including its content. When used as a setter, replaces the element with nodes parsed from the given string.
  void setOuterHTML(String arg);
  void setOuterText(String arg);


  
The element immediately preceding the given one in the tree, or null if there is no sibling element.
The scroll view height of an element.
  int getScrollHeight();


  
Gets/sets the left scroll offset of an element.
  int getScrollLeft();
  void setScrollLeft(int arg);


  
Gets/sets the top scroll offset of an element.
  int getScrollTop();
  void setScrollTop(int arg);


  
The scroll view width of an element.
  int getScrollWidth();


  
Controls spell-checking (present on all HTML elements)
  boolean isSpellcheck();
  void setSpellcheck(boolean arg);


  
An object representing the declarations of an element's style attributes.
Gets/sets the position of the element in the tabbing order.
  int getTabIndex();
  void setTabIndex(int arg);


  
The name of the tag for the given element.
  String getTagName();


  
A string that appears in a popup box when mouse is over the element.
  void setTitle(String arg);
  boolean isTranslate();
  void setTranslate(boolean arg);
  void setWebkitdropzone(String arg);


  
Removes keyboard focus from the current element.
  void blur();


  
Gives keyboard focus to the current element.
  void focus();


  
Retrieve the value of the named attribute from the current node.
  String getAttribute(String name);


  
Retrieve the value of the attribute with the specified name and namespace, from the current node.
  String getAttributeNS(String namespaceURIString localName);


  
Retrieve the node representation of the named attribute from the current node.
Retrieve the node representation of the attribute with the specified name and namespace, from the current node.
  Attr getAttributeNodeNS(String namespaceURIString localName);
Retrieve a set of all descendant elements, of a particular tag name, from the current element.
Retrieve a set of all descendant elements, of a particular tag name and namespace, from the current element.
  NodeList getElementsByTagNameNS(String namespaceURIString localName);


  
Check if the element has the specified attribute, or not.
  boolean hasAttribute(String name);


  
Check if the element has the specified attribute, in the specified namespace, or not.
  boolean hasAttributeNS(String namespaceURIString localName);
  Element querySelector(String selectors);
  NodeList querySelectorAll(String selectors);


  
Remove the named attribute from the current node.
  void removeAttribute(String name);


  
Remove the attribute with the specified name and namespace, from the current node.
  void removeAttributeNS(String namespaceURIString localName);


  
Remove the node representation of the named attribute from the current node.
  void scrollByLines(int lines);
  void scrollByPages(int pages);


  
Scrolls the page until the element gets into the view.
  void scrollIntoView();


  
Scrolls the page until the element gets into the view.
  void scrollIntoView(boolean alignWithTop);
  void scrollIntoViewIfNeeded(boolean centerIfNeeded);


  
Set the value of the named attribute from the current node.
  void setAttribute(String nameString value);


  
Set the value of the attribute with the specified name and namespace, from the current node.
  void setAttributeNS(String namespaceURIString qualifiedNameString value);


  
Set the node representation of the named attribute from the current node.
  Attr setAttributeNode(Attr newAttr);


  
Set the node representation of the attribute with the specified name and namespace, from the current node.
  Attr setAttributeNodeNS(Attr newAttr);


  
Returns whether or not the element would be selected by the specified selector string.
  boolean webkitMatchesSelector(String selectors);


  
Asynchronously asks the browser to make the element full-screen.
  void webkitRequestFullScreen(int flags);
Simulates a click on the current element.
  void click();
  Element insertAdjacentElement(String whereElement element);


  
Parses the text as HTML or XML and inserts the resulting nodes into the tree in the position given.
  void insertAdjacentHTML(String whereString html);
  void insertAdjacentText(String whereString text);
New to GrepCode? Check out our FAQ X