本文介绍了什么时候是window.location =" url"执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好, 示例代码如下( 开头的括号中的数字仅供参考)(完整的HTML文件是最后 (本文): (1)window.location =''http://www.google.com''; (2)alert(我还在这里!); (3)window.open(" http://www.slashdot。 com"," _blank"); 会发生什么,是在赋值后(1)理论上其余的 代码不应该执行,因为窗口应该加载一个 的新URL。但是在我的浏览器(GNU / Linux上的Firefox 1.0)中,浏览器也会执行(2)和(3)。 似乎窗口只加载了 脚本完成执行后的新内容。 这种行为是错误还是正确? 在我搜索的所有文件中没有提及何时应该加载新的 位置,如果立即或仅在脚本 完成执行后。 任何人都可以尝试使用IE吗? 谢谢 罗兰 完整档案: < html:html> < head> < script type =" text / javascript"> ; window.location =''http://www.google.com''; alert(我还在这里!); window.open(" http://www.slashdot.com"," _blank"); < / script> < / head> < body> 测试。 < / body> < / html:html>Hello,the example code is the following(the number in parentheses at thebeginning are just for reference)(The complete HTML file is at the endof this article):(1)window.location = ''http://www.google.com'';(2)alert("I''m still here!");(3)window.open("http://www.slashdot.com", "_blank");What happens, is that after the assignment (1) theoretically the restof the code shouldn''t execute, since the window should be loading anew URL. But in my browser(Firefox 1.0 on GNU/Linux) the browser alsoexecutes (2) and (3).It seems that the window is only loaded with the new content after thescript has finished executing.So is this behaviour wrong or correct?In all documentations I searched there is no mention of WHEN the newlocation should be loaded, if immediately or only after the scriptfinished executing.Can anyone try this with IE?Thank youRolandComplete file:<html:html><head><script type="text/javascript">window.location = ''http://www.google.com'';alert("I''m still here!");window.open("http://www.slashdot.com", "_blank");</script></head><body>Test.</body></html:html>推荐答案 < snip> 到底是什么?如果您不希望脚本在分配到 之后执行,那么位置属性就不会在分配后放置代码。 Richard。<snip>To what end? If you don''t want script to execute after the assignment tothe location property then don''t put code after the assignment.Richard. 赋值给 的位置属性那么就不要把代码放在分配。 < 帧可能。assignment tothe location property then don''t put code after the assignment. <<Frames maybe. 这篇关于什么时候是window.location =" url"执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!