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.
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.
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.
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.
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:
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/.
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.
This article is copyrighted. Please do not reproduce or distribute this article in whole or part, in any form.
It will appear on your page as:
How to Redirect Visitors to Another Web Page After a Set Amount of Time