|
Layers |
Document Object Model |
DIV Tags |
Non-Standard Elements |
Style Sheets
Document objects are often used as a means of accessing particular elements within a web page by referencing a member of an array. However, many commonly used object arrays were not a part of the Document Object Model standards and so are not supported by Netscape 6. References to unsupported object arrays will generate JavaScript errors.
document.tags
document.ids
document.classes
document.elementName
document.contextual
document.layer
DOM offers a function that web developers should use in order to access elements within the document. document.getElementById(elementID) is a method that will return the object reference based on the elementID specified. The reference can then be assigned to a variable, which can then be used to affect the object. For example:
In the HTML:
<HTML>
<BODY>
<DIV id="test">
</DIV>
</BODY>
</HTML>
|
In the JavaScript:
var i = document.getElementById("test");
i.style.marginLeft = ".5in";
|
DOM offers another function that web developers should use in order to access elements within the document. In this case, the function document.getElementsByTagName returns an ordered list of all elements with that tag name. For example:
x = document.getElementsByTagName("p");
y = x[0];
y.style.marginLeft = ".5in";
|
In addition to document.getElementsByTagName, DOM2 specification also allows for another function called document.getElementsByTagNameNS. This also returns an ordered list of tags, but this time only includes those that fall inside a specific namespace.
For more information, refer to:
Netscape DevEdge DOM Developer Central
|