asp.net.ph

Skip Navigation Links

document Object

Language References


HTML 2, 3.2, 4, 4.01, 5

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

document 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



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

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