Please visit our sponsors !
DHTML Document Object Model
Examples
Note: Most of the DHTML examples require Internet Explorer 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.
DOM
HTML 4.0 introduced the Document Object Model, which gives us access
opportunity to every element in the
document. It contains no functions or fancy layout tricks, it is more like a map
of all the elements, and we use this map to access the elements.
How to access the elements
A scripting language is needed. JavaScript is the most browser compatible
scripting language, so we use JavaScript. To make an element available for the
DOM, the element must define the id attribute.
<html>
<body>
<h1 id="header">My header</h1>
<script type="text/javascript">
header.style.color="red"
</script>
</body>
</html> |
The script changes the style of the header element, and produces this output.
The DHTML Object Model
| Object |
|
Explanation |
| window |
methods
properties |
The window object is the top object in the DHTML Object
Model, and gives you information about the window and the frames. |
| document |
methods
properties
collections |
The document object represents the HTML document, and gives
you access to the HTML elements. |
| navigator |
properties |
The navigator object gives you information about the user's
browser. |
| event |
properties
collections |
The event object gives you information about events that
occur. |
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
|