How to Redirect Visitors to Another Web Page After a Set Amount of Time

Automatically show a different page after a few seconds


How to Redirect Visitors to Another Web Page After a Set Amount of Time

by Christopher Heng, thesitewizard.com

Someone wrote to ask if there was some way his visitor could be given a certain amount of time to read a web page, and then to have that page automatically replaced with another. This guide answers that question.

Prerequisites

This article assumes that you know how to insert HTML into your web page. If you use a visual web editor, switch it into its HTML mode (or code mode, or whatever your editor calls it). Instructions on how to do this for Expression Web, BlueGriffon, Dreamweaver and KompoZer can be found in the links for those editors in this sentence that you're reading right now.

How to Redirect After A Period of Time

Although my visitor was prepared to use JavaScript or PHP to accomplish the task, you don't actually need those to redirect after a set amount of time has elapsed. The facility is already available in HTML.

For example, if you wanted to redirect your visitors after (say) two seconds to thesitewizard.com's main page, the following code, placed in the HEAD section of your HTML, will do the trick.

<meta http-equiv="refresh" content="2;URL=https://www.thesitewizard.com/">

If you don't know where the HEAD section is, switch to the HTML source for your web page, and scroll to the very beginning of the document. Place the code above into a separate blank line immediately above </head>. Notice that I said "above </head>" and NOT above <head>. The <head> tag marks the start of the HEAD section, and </head> ends it. The META tag I provided above must be placed between the start and end HEAD tags.

Replace the 2 in my example to the actual number of seconds you want the current page to be displayed. It can even be 0 (ie, zero) if you want the browser to start loading the new page immediately after the current one is loaded.

The new web address should immediately follow "URL=", in place of my example address. It does not have to be an absolute URL if the new page resides on the same domain. For example, the following code redirects to the "index.shtml" page in the same directory (ie, folder) as the current page after 5 seconds.

<meta http-equiv="refresh" content="5;URL=index.shtml">

It's possible to use this tag to reload the same page after a set amount of time (for instance, if your page is constantly being updated). In such a case, you can omit the URL portion:

<meta http-equiv="refresh" content="60">

The above example reloads the same page after 60 seconds.

Copyright © 2019 Christopher Heng. All rights reserved.
Get more free tips and articles like this, on web design, promotion, revenue and scripting, from https://www.thesitewizard.com/.

thesitewizard™ News Feed (RSS Site Feed)  Subscribe to thesitewizard.com newsfeed

Do you find this article useful? You can learn of new articles and scripts that are published on thesitewizard.com by subscribing to the RSS feed. Simply point your RSS feed reader or a browser that supports RSS feeds at https://www.thesitewizard.com/thesitewizard.xml. You can read more about how to subscribe to RSS site feeds from my RSS FAQ.

Please Do Not Reprint This Article

This article is copyrighted. Please do not reproduce or distribute this article in whole or part, in any form.

Related Articles

New Articles

Popular Articles

How to Link to This Page

It will appear on your page as:

How to Redirect Visitors to Another Web Page After a Set Amount of Time





Home
Donate
Contact
Link to Us
No Spam Policy
Privacy Policy
Topics
Site Map

Getting Started
Web Design
Search Engines
Revenue Making
Domains
Web Hosting
Blogging
JavaScripts
PHP
Perl / CGI
HTML
CSS
.htaccess / Apache
Newsletters
General
Seasonal
Reviews
FAQs
Wizards

 

 
Free webmasters and programmers resources, scripts and tutorials
 
HowtoHaven.com: Free How-To Guides
 
Site Design Tips at thesitewizard.com
Find this site useful?
Please link to us.