Creating Automatic Refreshes and Redirects - 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:

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:

To refresh the current page, simply place its absolute URL in the refresh tag. Tip 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:

This tag causes the document to be immediately expired in the cache and, hence, not cached at all.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

HTML Topics