How to redirect a page after sometime in pure javascript. There are several ways to redirect
a page in javascript and jquery after sometime. The below example showing how to redirect a 
page after sometime in pure javascript.

<!DOCTYPE html><!DOCTYPE html>

<html>

<head>

<title>Rediret to google.com</title>

</head>

<body>

<p>You will be redirected in <span id="redirect">5</span> second.</p>

<script> document.addEventListener("DOMContentLoaded", function(event) {

window.setInterval(function() {

var timeLeft    = document.getElementById('redirect').innerHTML;

if(eval(timeLeft) == 0){

window.location.href="http://www.google.com";

}else{

document.getElementById('redirect').innerHTML=eval(timeLeft)- eval(1);                   }    }, 5000); });

</script>

</body>

</html>

Leave comment

Your email address will not be published. Required fields are marked with *.