HTML and CSS Reference
In-Depth Information
Table 11.2 Some document Object Properties
Property
What It Describes
bgColor, fgColor
Determines the background color and text color, related to the HTML
<body> tag.
cookie
Allows reading and writing HTTP cookies (see Chapter 16, “Cookies”).
domain
A security property for Web servers in the same domain.
lastModified
A string with the date when the page was last modified.
linkColor, alinkColor,
vlinkColor
Determines the color of unvisited links, active links, and visited links,
respectively; related to link attributes of the HTML <body> tag.
location
The URL of the document (deprecated).
referrer
URL of the document that linked the browser to this document.
title
The title of the current document, related to the text between the
<title></title> tags found in the head of the document.
URL
A string containing the URL of the document.
As shown in the output of Example 11.1 (see Figure 11.2), the document has a large
assortment of properties. Most of these properties, those containing the word “Node,”
will be used with the standard W3C DOM Levels 1 and 2. The newer versions of the
DOM give you the ability to get access to and manipulate all of the HTML/XML elements
in the document.
EXAMPLE 11.1
<html>
<head><title>Looping through Object Properties</title></head>
<body>
<script type="text/javascript">
1
var props=new Array();
2
for ( var property in window.document){
3
props.push(property);
}
4
for(i=0;i<props.length; i++){
5
document.write( props[i] + " ");
if( i>0 && i%4 == 0 ){
document.write("<br />");
}
}
</script>
</body>
</html>
 
Search WWH ::




Custom Search