Sunday, 2 March 2014

Redirect After 'X' Seconds in JQUERY

<!doctype>
<html>
  <head>
     <title>Redirect in Jquery</title>

  <style>
   #timeLeft{
     color:red;
   }
  </style>
  </head>
  <body>
   <h1>You will be redirect to actual Page After <span id="timeLeft" >20</span> Seconds Thanks</h1>

   <script src='http://code.jquery.com/jquery-1.11.0.min.js'></script>
   <script>
$(document).ready(function() {
window.setInterval(function() {
var timeLeft = $("#timeLeft").html();
if(eval(timeLeft) == 0){
window.location= ("http://www.google.com");
}else{
$("#timeLeft").html(eval(timeLeft)- eval(1));
}
}, 1000);
});    
</script>
  </body>
</html>

Live Demo

No comments:

Post a Comment

Thank your for your comment..your submitted coment will be live after admin approval