aspxtreme

document Object

HTML Elements/DHTML Objects


Represents the HTML document in a given browser window.

Remarks

The document object is the root of the document tree, and provides the primary access to the document's data.

We use the document object to retrieve information about the document, to examine and modify the HTML elements and text within the document, and to process events.

The document object is available at all times. We can retrieve the object by applying the document property to a window or an element object. If used by itself, document represents the document in the current window.

Members



Example

The following example checks for the document TITLE and displays the title, if not null, in an alert box.

if ( document.title != "" )
   alert ( "The title of this document is \n" + document.title )

 Show me 

The following example shows how a script can be used to dynamically retrieve property values from the current document.

 Show me 

The sample below uses a simple event handler to track and display the current position of the mouse. The coordinates shown are relative to the upper-left corner of the document.

var x, y;
function mouseMove ( e ) {
   x = ( ie4up ) ? event.offsetX : e.pageX;
   y = ( ie4up ) ? event.offsetY : e.pageY;
   status = 'x = ' + x + ' y = ' + y;
   coords.innerText = 'x = ' + x + ' y = ' + y;
   return true;
}
document.onmousemove = mouseMove;
if ( ns4 || ns6 ) document.captureEvents ( Event.MOUSEMOVE );

 Show me 

Applies To

window



Books and more ...

Contents
HTML Elements / DOM Objects
HTML Element Attributes
CSS Attributes
DOM Object Properties
DOM-compliant Events Reference
DOM Methods Reference
DOM Collections Reference
 


Suggested Reading



Previous page Back to top Next page

Check out related books at Amazon

© 2000-2008 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support aspxtreme