javascript - When using location.href to jump to a page, it does not jump immediately?
怪我咯
怪我咯 2017-06-28 09:28:41
0
3
1043
location.href="login.html"

I found that it does not jump immediately after executing this statement, but after all the JS statements following the statement are executed, the jump is performed. Why?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(3)
淡淡烟草味

The assignment of

window.location.href will not interrupt the execution of Javascript. So it’s best to add a statement like return at the end to end it

ringa_lee

If you need to jump directly without executing the following, you can add return false;

after the jump
Ty80

No, I tested it and it didn’t happen. It jumps immediately. You can post your code and see if it has anything to do with your code, such as whether it is in an asynchronous function

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template