Redirect website after certain amount of time
Sol 1:
http-equiv="refresh" content="3;url=http://www.somewhere.com/" />
ContentMiddleAd
Redirecting in 3 seconds...
Note that use of
meta refresh is deprecated and frowned upon these days, but sometimes it's the only viable option (for example, if you're unable to do server-side generation of HTTP redirect headers and/or you need to support non-JavaScript clients etc).
Sol 2:
If you want greater control you can use javascript rather than use the meta tag. This would allow you to have a visual of some kind, e.g. a countdown.
Here is a very basic approach using
setTimeout()ContentMiddleAd
You will be redirected in 3 seconds
ContentMiddleAd
var timer = setTimeout(function() { window.location='http://example.com' }, 3000);Sol 3:
ContentMiddleAd
Here's a complete (yet simple) example of redirecting after X seconds, while updating a counter div:
id="counter">5
setInterval(function() {
var div = document.querySelector("#counter");
var count = div.textContent * 1 - 1;
div.textContent = count;
if (count <= 0) {
window.location.href="https://example.com";
}
}, 1000);
The initial content of the
Sol 5:counter div is the number of seconds to wait.ContentMiddleAd
Place the following HTML redirect code between the and tags of your HTML code.
The above HTML redirect code will redirect your visitors to another web page instantly. The content="3; may be changed to the number of seconds you want the browser to wait before redirecting. 4, 5, 8, 10 or 15 seconds, etc.
|
Sol 6:
http-equiv="refresh" content="3;url=http://www.google.com/" />
really Good blog post.provided a helpful information.I hope that you will post more updates like thisHadoop Admin Online Course India
ReplyDelete