Reputation: 43
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
Reputation: 1647
Try this
setTimeout(function() {
window.location = "new url";
}, 5000);
Upvotes: 0
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
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
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
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