Main Page

HTML contains

you want to track where users are coming from (perhaps to see if someone visited your site via Google
or another search engine). But again, this can also be handled server-side.
The
title
property is read/write, so you can change the title of your page at any time regardless of
what the HTML contains. This is particularly useful when a site uses a frameset and only one frame is
changing while the overall frameset remains unchanged. Using this property, you can change the title
(which is displayed in the overall browser title bar) to reflect the new page loaded into the frame:
top.document.title = “New page title”;
The
URL
property is also read/write, so you can use it to retrieve the URL of the current page, or you can
set it to a new URL, which causes the window to navigate there. For example:
document.URL = “http://www.wrox.com/”;
As mentioned previously, the
document
object also has a number of collections providing access to vari-
ous parts of the loaded page. These collections are outlined in the following table:
Collection
Description
anchors
Collection of all anchors in the page (represented by
<a
name=”anchorname”></a>
)
applets
Collection of all applets in the page
embeds
Collection of all embedded objects in the page (represented by the
<embed/>
tag)
forms
Collection of all forms in the page
images
Collection of all images in the page
links
Collection of all links in the page (represented by
<a href=
”somewhere.htm”></a>)
Similar to the
window.frames
collection, each of the
document
collections is indexed both by number
and by name, meaning that you can access an image by
document.images[0]
or
document.images
[“image_name”]
. Consider the following HTML page:
<html>
<head>
<title>Document Example</title>
</head>
<body>
<p>Welcome to my <a href=”home.htm”>home</a> away from home.</p>
<img src=”home.jpg” align=”right” name=”imgHome” />
<form method=”post” action=”submit.cgi” name=”frmSubscribe”>
<input type=”text” name=”txtEmail” />
<input type=”submit” value=”Subscribe” />
</form>
</body>
</html>
150
Chapter 5
08_579088 ch05.qxd 3/28/05 11:37 AM Page 150


JavaScript EditorFree JavaScript Editor     Ajax Editor


©