JavaScript Tutorials - Herong's Tutorial Examples - Version 2.21, by Dr. Herong Yang
DOM Level 0 - Example
This section provides a tutorial example of DOM Level 0 objects and attributes that are supported in Netscape 3 and IE 3.
DOM Level 0 - No formal specifications published: A collection of HTML document functionalities offered by Netscape Navigator version 3.0 and Microsoft Internet Explorer version 3.0.
Here is a tutorial example of using DOM Level 0 objects and properties:
<html>
<!-- DOM_Level_0_Example.html
Copyright (c) 2013 by Dr. Herong Yang, herongyang.com
-->
<head>
<title>DOM Level 0 Example</title>
<script type="text/javascript">
var colorID = 0;
function changeColor() {
if (colorID == 0 )
document.bgColor = "#ff8888";
else if (colorID == 1 )
document.bgColor = "#88ff88";
else if (colorID == 2 )
document.bgColor = "#8888ff";
else if (colorID == 3 )
document.bgColor = "#888888";
document.forms[0].elements[0].value = document.bgColor;
colorID = (colorID+1)%4;
}
</script>
</head>
<body>
<pre>
<script type="text/javascript">
document.writeln("\"documnet\" attribute initial values:");
document.writeln(" alinkColor = "+document.alinkColor);
document.writeln(" background = "+document.background);
document.writeln(" bgColor = "+document.bgColor);
document.writeln(" fgColor = "+document.fgColor);
document.writeln(" linkColor = "+document.linkColor);
document.writeln(" vlinkColor = "+document.vlinkColor);
</script>
</pre>
<form>
Current document.bgColor:
<input type="text" name="bgcolor" value="#ffffff"><br/>
<input type="button" value="Click to change background color"
onClick="changeColor();"/>
</form>
</body>
</html>
We should test this JavaScript in Netscape Navigator version 3.0 or Microsoft Internet Explorer (IE) version 3.0.
But DOM Level 0 is still supported by IE version 6. Here is how this JavaScript page will look like on IE 6:
Table of Contents
ECMAScript Language Specification and JavaScript Dialects
Data Types, Variables and Expressions
Creating, Accessing, and Manipulating Arrays
Defining and Calling Functions
Web Browser Supporting JavaScript
Server-Side and Client-Side Web Scripting
Defining Your Own Object Types
Inheritance of Properties and Methods through the Prototype Object Chain
'jrunscript' - JavaScript Shell Command from JDK
Using Functions as "Function" Objects
Introduction to Built-in Object Types
►W3C's Document Object Model (DOM) Specifications
Overview of DOM Specifications
DOM Level Test - document.implementation.hasFeature
Inheritance vs. Flattened Views of the API
A Web Document as A Tree of Different Interfaces
A Web Document as A Tree of Nodes
Dump Document in a New Window - JavaScript Source
Dump Document in a New Window - Firefox 2.0 Result