0

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?

1
  • you don't need jQuery for everything...just do setTimeout(function(){window.location='something.html';},5000) Commented Aug 16, 2013 at 4:39

5 Answers 5

6
<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.

Sign up to request clarification or add additional context in comments.

Comments

5

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/" />

1 Comment

Awesome! This is great!
1

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

Comments

0

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
});

Comments

0

Try this

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.