Redirect the page using javascript without .htaccess | 2my4edge

19 August 2013

Redirect the page using javascript without .htaccess

here i'm going to show you that, how to make redirect the page without using .htaccess, here i'm going to use only javascript and using jquery plugin. and we have discussed some tutorials about .htacess. and without using .htaccess and without using refresh meta tag, we are going to see how to make redirect by using javascript. let see the that.
redirect the page without .htaccess
DOWNLOAD                 LIVE DEMO

as like the above image, the countdown get starts to go for windows location page. here we are going to see the script what we need to make this redirection. it should need jquery min file and the below script.

the highlight link is the url, where you have to redirect.
<script type="text/javascript" src="jquery.min.js"></script>
$(document).ready(function() {  
    window.setInterval(function() {
    var timeLeft    = $("#sec").html();                             
        if(eval(timeLeft) == 0){
                window.location= ("");                   
            $("#sec").html(eval(timeLeft)- eval(1));
    }, 1000); 

this code comes in the body tag. eval makes the countdown.
<div class="container">
  <h1 align="center">redirect within <span id="sec" >20</span> Seconds</h1>

within the id="sec" what you given, that will make countdown from that number. then you will redirect to the page of what you given in the window.location url. 
that's it. try this.


No comments:

Post a Comment