• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 24. Head Elements > Example: Automatic Refreshing

Example: Automatic Refreshing

With meta tags, you can describe a lot, including when the current page is no longer current. You could then use setTimeout() (which I describe in Chapter 15) to force the browser to retrieve a new version of the page on schedule. (The reference at the beginning of this element's section states Netscape supports refreshing by meta tags as well. Internet Explorer has deprecated the http-equiv="refresh" attribute value, but it still works as of version 5.5.) Listing 24.2 is a page that reloads every 10 seconds.

Listing 24.2. Automatically Refreshing a Page

<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>This is a test of meta refreshing</title>
<meta name="Author" content="Alexander J. Vincent" />
<meta http-equiv="Refresh" content="10" id="metarefresh" />
</head>
<body>
<p>The time now is&nbsp;
<script language="JavaScript" type="text/javascript">
<!—
If (document.getElementByID) {
document.write(new Date()+"<br/ >")
document.write(document.getElementById('metarefresh').httpEquiv)
document.write(" in 10 seconds.")
}
//—>
</script>
</p>
<!— Note:
This example will not work in IE4
Or Nav4
Results:
The time now is (date string)
Refresh in 10 seconds.
—>
</body>
</html>


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint