简体   繁体   中英

redirect to home page after 3 seconds

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

您可以使用 setTimeout 来设置用户将被重定向的时间,并使用 window.location 来设置用户应该被重定向到的 URL

setTimeout(function(){ window.location = "http://www.yoururl.com"; },3000);
<script type="text/javascript">
        $(document).ready(function () {
            setTimeout(function () {
                window.location = "you Home Page URL";
            }, 3000);
        });
    </script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM