场景是这样的。一个网页包含:
- 一些 DIV 的可见性可以通过 JavaScript(从超链接触发)进行切换
- 一个“提交”按钮,其响应时间大约需要 5 秒
超链接代码为
<a href="javascript:void null;" onclick="MyFunction()">foo</a>
用户:
- 按“提交”。
- 在等待响应时,他单击了超链接,并触发了切换 DIV 可见性的 JavaScript(不执行其他请求)。
- 在 Internet Exporer 6 中,浏览器停止等待第一个请求。
在其他浏览器中不会出现此问题,即使用户使用 DIV,第一个请求也会被正确处理,并且我们会导航到下一页。
有谁知道这可能是什么原因造成的?这是一个已知的 IE6 问题吗?
最佳答案
是的,这是IE6问题,GET请求是由超链接上的Javascript操作触发的( 其中 href 设置为“javascript:...”)。
e.g. if your JavaScript calls
someForm.submit()
and the method isGET
, there will beNO
response (the request is definately sent though)
http://webbugtrack.blogspot.com/2007/09/bug-223-magical-http-get-requests-in.html
您需要修改链接,例如:
<a href="#bogushash" onclick="MyFunction()">foo</a>
^^^^^^^^^^
或者始终将链接设置为 return false;
<a href="javascript:void null;" onclick="MyFunction();return false;">foo</a>
^^^^^^^^^^^^^
关于javascript - 当 JavaScript 执行时,Internet Explorer 6 中止页面请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/538178/