Thursday, April 1, 2010
Creating Automatic Refreshes and Redirects
Posted by devlevis | Thursday, April 1, 2010 | Category:
create automatic refreshes and redirects using html code,
free html course,
how to create automatic refreshes using html code,
html tricks,
learn html
|
Meta tags can also be used to refresh a document’s content or redirect a client browser
to another page. Refreshing a document is useful if it includes timely, dynamic data,
such as stock prices. Redirection comes in handy when a document moves—you
can use a redirect to automatically redirect a visitor to the new document.
To refresh or redirect a document, use the http-equiv "refresh" option in a <meta>
tag. This option has the following form:
<meta http-equiv-"refresh" content-"seconds_to_wait; url">
For example, suppose that a page on your site (example.com) has moved. The page
used to be on the root of the server as bio.html, but now the page is in a bio
directory as index.html (/bio/index.html). However, you want visitors who
previously bookmarked the old page to be able to get to the new page. Placing the
following document in the server’s root (as bio.html) would cause visitors to
automatically be redirected to the new page after a three-second wait:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
â"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>My Bio has Moved!</title>
<meta http-equiv-"pragma" content-"no-cache">
<meta http-equiv-"refresh" content-"$3$;
URL= http://www.example.com/bio/index.html">
</head>
<body>
<p>My bio has moved. You will be redirected to the new page
in 3 seconds, or you can click the link below.</p>
<a href-"http://www.example.com/bio/index.html">My new
bio.</a>
</body>
</html>
â"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>My Bio has Moved!</title>
<meta http-equiv-"pragma" content-"no-cache">
<meta http-equiv-"refresh" content-"$3$;
URL= http://www.example.com/bio/index.html">
</head>
<body>
<p>My bio has moved. You will be redirected to the new page
in 3 seconds, or you can click the link below.</p>
<a href-"http://www.example.com/bio/index.html">My new
bio.</a>
</body>
</html>
To refresh the current page, simply place its absolute URL in the refresh tag.
TRICK :Using the pragma no-cache meta tag along with the refresh tag is always
a good idea. This helps keep the browser from caching the document and
displaying the cached copy of the document instead of the updated document.
Because different browsers treat the no cache pragma differently, it is also a
good idea to add an expires meta tag, as shown below:
<meta http-equiv-"expires" content-"0">
This tag causes the document to be immediately expired in the cache and,
hence, not cached at all.
Subscribe to:
Post Comments (Atom)


Currently have 0 comments: