Please visit our sponsors !
DHTML Document Object Model
The Document Object Model gives us access
to every element in a
document.
Examples
Note: Most of the DHTML examples require IE 4.0 or
higher.
Element access
How to access an element and change the style.
Attribute change
How to access an image element and change the "src" attribute.
innertext access
How to access and change the inner text of an element.
How to access an element?
The element must have an id attribute defined and a scripting language is
needed. JavaScript is the most browser compatible scripting language, so we use
JavaScript.
<html>
<body> <h1 id="header">My header</h1> <script type="text/javascript">
header.style.color="red"
</script> </body>
</html> |
The script changes the color of the header element, and produces this output.
The DHTML Document Object Model
Object |
|
Description |
window |
methods
properties |
The window object is the top level object in the DHTML DOM.
It contains information about the window and the frames |
document |
methods
properties
collections |
The document object represents the HTML document, and is
used to access the HTML elements inside the document |
navigator |
properties |
The navigator object contains information about the user's
browser |
event |
properties
collections |
The event object contains information about events that
occurs |
Jump to: Top of Page
or HOME or
Printer friendly page
Search W3Schools:
What Others Say About Us
Does the world know about us? Check out these places:
Dogpile
Alta Vista
MSN
Google
Excite
Lycos
Yahoo
Ask Jeeves
We Help You For Free. You Can Help Us!
W3Schools is for training only. We do not warrant its correctness or its fitness for use.
The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our
terms of use and
privacy policy.
Copyright 1999-2002 by Refsnes Data. All Rights Reserved
|