JT Nolan
JT Nolan

Reputation: 43

How Can I Make a Redirect Page in Jquery?

I want to build a page that displays html for a short while and then redirects the user to another URL without opening a new window. How can this be done quickly in Jquery?

Upvotes: 0

Views: 23912

Answers (5)

Eswara Reddy
Eswara Reddy

Reputation: 1647

Try this

setTimeout(function() {
   window.location = "new url";
}, 5000);

Upvotes: 0

roycable
roycable

Reputation: 301

If you're not wanting to open the URL in a new window use window.location.href = xx

setTimeout(function(){
   window.location.href = 'http://www.google.com';
},5000);// after 5 seconds

Upvotes: 1

xdazz
xdazz

Reputation: 160833

Doesn't need javascript, just add the meta tag in the head:

// for 5 seconds
<meta http-equiv="refresh" content="5; url=http://www.example.com/" />

Upvotes: 5

Sonny Ng
Sonny Ng

Reputation: 2051

<script type="text/javascript">
    window.onload = function() {
        setTimeout(function() {
            window.location = "your link";
        }, 5000);
    };
</script>

After 5 second, it will redirect. replace"your link" with the link you want.

Hope it helps.

Upvotes: 6

Rohan Kumar
Rohan Kumar

Reputation: 40639

Try this,

// you can use jquery document ready function to call your code after DOM ready
$(document).ready(function(){
    setTimeout(function(){
       window.open('your url to open');
    },5000);// after 5 seconds
});

Upvotes: 0

Related Questions