admin管理员组文章数量:1323524
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
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
Share Improve this question asked Aug 2, 2018 at 18:28 aceace 1481 gold badge3 silver badges17 bronze badges 5-
1
That's not the right way to do it, but you can use
setTimeout(function(){ window.location = '/home'}, 3000)
, for this kind of requests i remend you learn more about promises – Pedro Sturmer Commented Aug 2, 2018 at 18:29 - just out of curiosity why can't you show your homepage directly? – karthick Commented Aug 2, 2018 at 18:31
- 1 This 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. – Alex Howansky Commented Aug 2, 2018 at 18:32
- im just doing what my adviser want. haha – ace Commented Aug 2, 2018 at 18:36
- Possible duplicate of Page Redirect after X seconds wait using JavaScript – Fobos Commented Aug 2, 2018 at 18:38
2 Answers
Reset to default 4You 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."; },3000);
<script type="text/javascript">
$(document).ready(function () {
setTimeout(function () {
window.location = "you Home Page URL";
}, 3000);
});
</script>
本文标签: javascriptredirect to home page after 3 secondsStack Overflow
版权声明:本文标题:javascript - redirect to home page after 3 seconds - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742133570a2422271.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论