Changes

JavaScript Document Object

996 bytes added, 20:27, 14 May 2007
Document Object Properties
<td>vlinkColor<td>The color to be used when displaying links in the document which have been visited by the current user</td>
</table>
 
== Using the JavaScript Document Object ==
 
Now that we have seen the methods and properties that are avialable with the Document object we can begin explore how to use them:
 
=== Writing text to a document ===
 
The document object ''open()'' and ''write()'' methods can be used to dynamically write text to a web page. The following example contains both some text contained in the HTML file, togetehr with some JavaScript to write additional text into the page:
 
<pre>
 
<html>
<head>
<title>JavaScript Document Object Example</title>
</head>
<body>
<p>
This is a line of text specified in the HTML file
</p>
<script language="javascript" type="text/javascript">
document.open()
document.write("This is a line of text written to the document using JavaScript");
</script>
 
</body>
</html>
 
</pre>
 
The above example will display the following in the browser window:
 
<pre>
This is a line of text specified in the HTML file
This is a line of text written to the document using JavaScript
</pre>