redirect to home page after 3 seconds
11,345
Solution 1
You can use setTimeout to set time after which user will be redirected and window.location to set the URL where the users should be redirected
setTimeout(function(){ window.location = "http://www.yoururl.com"; },3000);
Solution 2
<script type="text/javascript">
$(document).ready(function () {
setTimeout(function () {
window.location = "you Home Page URL";
}, 3000);
});
</script>
Related videos on Youtube
Comments
-
ace almost 2 years
i created a simple login that the user will fill in and after successfully login he will redirectly go another page that has a message login successful, Now my problem is after the user redirect to the login success massage page is there a way to set 3seconds on that page and after that the user will go back to home page after 3 seconds? hope you can help me. Thanks
-
Pedro Sturmer almost 6 yearsThat's not the right way to do it, but you can use
setTimeout(function(){ window.location = '/home'}, 3000)
, for this kind of requests i recommend you learn more about promises -
karthick almost 6 yearsjust out of curiosity why can't you show your homepage directly?
-
Alex Howansky almost 6 yearsThis is poor UI design, don't make the user wait for anything. Just redirect back the home page immediately. Logging in should only generate an unavoidable message if the login fails.
-
ace almost 6 yearsim just doing what my adviser want. haha
-
Fobos almost 6 yearsPossible duplicate of Page Redirect after X seconds wait using JavaScript
-