Using the meta element for client-pull
Client-pull refers to the ability of the browser (the client) to automatically request (pull) a new document from the server. The effect for the user is that the page displays, and after a period of time, automatically refreshes with new information or is replaced by an entirely new page. This technique can be used to automatically redirect readers to a new URL (for instance, if an old URL has been retired).
Warning
Be aware, however, that the W3C strongly discourages the use of this method for automatic forwarding in favor of server-side redirects for reasons of accessibility.
Client-pull uses the refresh
attribute value, first introduced by Netscape. It tells the browser to wait a specified number of seconds (indicated by an integer in the content
attribute) and then to load a new page. If no page is specified, the browser just reloads the current page. The following example instructs the browser to reload the page after 15 seconds (assume there’s something fancy happening on the server side that puts updated information in the HTML document):
<meta http-equiv="refresh" content="15" />
To reload a different file, provide the URL for the document within the content
attribute:
<meta http-equiv="refresh" content="1; url=http://doc2.html" />
Note that there is only a single set of quotation marks around the value for content
. Although URLs usually require their own quotation marks, these are omitted within the context of the content
attribute.
Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.