[英]Internet Explorer only part loading JavaScript/CSS
I'm having trouble with my local development environment where IE (6 through to 8) is only part loading JavaScript/CSS files. 我在本地开发环境中遇到了麻烦,其中IE(6至8)只是部分加载JavaScript / CSS文件。 It throws random errors at random places in jquery.min.js
every time I refresh, which suggested to me that it's trying to execute before it's finished loading or the connection was closed before it finished loading. 每次刷新时,它都会在jquery.min.js
中的随机位置引发随机错误,这向我提示它正在尝试在完成加载之前执行,或者在完成加载之前关闭了连接。
I've looked at the responses using Charles and Apache is returning the correct content-length
header for the files I'm having trouble with but the text response is always truncated. 我已经使用Charles查看了响应,Apache会为遇到问题的文件返回正确的content-length
标头,但文本响应始终会被截断。
I also tried disabling g-zip compression, as I noticed that responses to IE don't have the Content-Encoding: g-zip
header, but that breaks things in Firefox (in the same way) and doesn't fix the problem with IE. 我还尝试禁用g-zip压缩,因为我注意到对IE的响应没有Content-Encoding: g-zip
标头,但这会破坏Firefox中的内容(以相同的方式),并且无法解决以下问题: IE浏览器
I've looked at my Apache config and it is no different to the staging server where I'm not experiencing these issues. 我已经看过我的Apache配置,它与没有遇到这些问题的登台服务器没有什么不同。
I've changed this line: 我更改了这一行:
BrowserMatch bMSIEs(7|8) !no-gzip !gzip-only-text/html
to this: 对此:
BrowserMatch \\bMSIE !no-gzip !gzip-only-text/html
In my config and that seems to fix it, still not sure why it's working differently locally. 在我的配置中,这似乎可以解决问题,仍然不确定为什么它在本地的工作方式有所不同。
The directives causing the browser to load stuff - scripts, images, etc. are executed asynchronously. 导致浏览器加载内容的指令-脚本,图像等是异步执行的。 If your javascript is not self contained I mean relies on anything from any other file, you should not try to execute it using inline statements - you have no way of knowing whether this other file completed loading. 如果您的JavaScript不是自包含的,我的意思是依赖于任何其他文件中的任何内容,则不应尝试使用内联语句执行它-您无法知道此其他文件是否已完成加载。
What you need to do is to trigger execution from the page loaded event 您需要做的是从页面加载事件触发执行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.