迈克詹姆斯乱战:引用 诡异的IE6环境JS加载不执行问题

来源:百度文库 编辑:九乡新闻网 时间:2024/04/30 03:25:52
今天也遇到这个问题,郁闷

引用

段玉诡异的IE6环境JS加载不执行问题
 最近遇到一个狂郁闷的问题, 在firefox和IE7环境下是OK的, 而在IE6环境下80%以上概率死活不行。问题描述如下:
 在页面b.html中存在如下


其中b.do返回的http header如下:
HTTP/1.1 200 OK
Server: nginx/0.6.34
Date: Fri, 27 Feb 2009 02:59:41 GMT
Content-Type: text/html;charset=GBK
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires: Fri, 27 Feb 1970 02:59:41 GMT
Vary: Accept-Encoding
Content-Encoding: gzip

直接在地址栏输入b.html或者刷新b.html, b.do这个js 都是可以正常加载并执行的

而现在的情况是在 a.html中点击一个链接当前页面刷新为b.html,这个时候b.do可以加载,但是不执行了。

解决问题思路如下:
1. b.do返回的是header中content-type是:text/html改为
Content-Type: text/javascript;charset=GBK 或者Content-Type: application/x-javascript;charset=GBK
  not work

2. 放一个b.js文件,返回header如下:
HTTP/1.1 200 OK
Server: nginx/0.6.34
Date: Fri, 27 Feb 2009 02:50:39 GMT
Content-Type: application/x-javascript
Last-Modified: Fri, 13 Feb 2009 09:22:41 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Expires: Fri, 06 Mar 2009 02:50:39 GMT
Cache-Control: max-age=604800
Content-Encoding: gzip

这个可以正常加载并执行,那是啥问题呢, 要比较这两个header的区别了。
与小蔡和ce一起分析, 应该gzip和Cache-Control、Expires的区别。

3. 将Expires header去掉, not works
4.将gzip压缩去掉, it works
   这个需要修改服务器的配置,比较麻烦
5. 去除Cache-Control header或者设置Cache-Control为空, it works
   不过这个存在问题,因为b.do是个动态请求不能被缓存的, 萎缩的做法是: b.do?1232
加个随机数吧。

http://www.akmattie.net/blog/2007/11/10/javascript-frames-ie-6-gzip-no-cache-header-trouble/
" and it seems that they no longer gzip the response when serving up their www.google.com/jsapi application."
:)