如何让jquery.couch.app.js与IE8一起使用 [英] how to get jquery.couch.app.js to work with IE8

查看:90
本文介绍了如何让jquery.couch.app.js与IE8一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在IE7和IE8中的Windows XP SP3(在所有兼容模式下)和IE8中的Windows 7旗舰版(在所有兼容模式下)测试了这一点,并且两者都失败了。我正在运行 couchapp 存储库中的最新HEAD。这在我的OSX 10.6.3开发机器上工作正常。我在Windows 7旗舰版上测试了Chrome 4.1.249.1064(45376)和Firefox 3.6,它们都运行良好。与OSX 10.6.3上的Safari 4和Firefox 3.6一样

I have tested this on Windows XP SP3 in IE7 and IE8 ( in all compatibility modes ) and Windows 7 Ultimate in IE8 (in all compatiblity modes) and it fails the same way on both. I am running the latest HEAD from the the couchapp repository. This works fine on my OSX 10.6.3 development machine. I have tested with Chrome 4.1.249.1064 (45376) and Firefox 3.6 on Windows 7 Ultimate and they both work fine. As do both Safari 4 and Firefox 3.6 on OSX 10.6.3

以下是错误消息


网页错误详情

Webpage error details

用户代理:Mozilla / 4.0(兼容;
MSIE 8.0; Windows NT 6.1; Trident / 4.0;
SLCC2; .NET CLR 2.0.50727; .NET CLR
3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)时间戳:星期三,28四月
2010 03:32:55 UTC

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0) Timestamp: Wed, 28 Apr 2010 03:32:55 UTC

消息:对象不支持此
属性或方法行:159字符:7
代码:0 URI:
< a href =http://192.168.0.105:5984/test/_design/test/vendor/couchapp/jquery.couch.app.js =nofollow noreferrer> http://192.168.0.105:5984/test /_design/test/vendor/couchapp/jquery.couch.app.js

这里是冒犯一点代码,适用于Chrome,Firefox和Safari就好了。如果说失败是从文件 qs.forEach()的那一行master / vendor / _attachments / jquery.couch.app.jsrel =nofollow noreferrer> jquery.couch.app.js

and here is the "offending" bit of code, which works on Chrome, Firefox and Safari just fine. If says the failure is on the line that starts qs.forEach() from the file jquery.couch.app.js

  157 var qs = document.location.search.replace(/^\?/,'').split('&');
  158 var q = {};
  159 qs.forEach(function(param) {
  160   var ps = param.split('=');
  161   var k = decodeURIComponent(ps[0]);
  162   var v = decodeURIComponent(ps[1]);
  163    if (["startkey", "endkey", "key"].indexOf(k) != -1) {
  164     q[k] = JSON.parse(v);
  165   } else {
  166    q[k] = v;
  167   }
  168 });


推荐答案

forEach()是最近添加到JavaScript规范,因此并非所有浏览器都支持它。

forEach() is a function that's recently added to the JavaScript specification, so not all browsers support it.

您可以在MDC上阅读:
https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/forEach

You can read about it at MDC: https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/forEach

在兼容性下,您会找到一个使forEach()可用的代码段。

Under "Compatibility", you'll find a snippet that makes forEach() available.

if (!Array.prototype.forEach)
{
  Array.prototype.forEach = function(fun /*, thisp*/)
  {
    var len = this.length >>> 0;
    if (typeof fun != "function")
      throw new TypeError();

    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this)
        fun.call(thisp, this[i], i, this);
    }
  };
}

因此,将上面的代码复制并粘贴到脚本中,forEach()应该工作。

So, copy and paste the code above to your script and forEach() should work.

这篇关于如何让jquery.couch.app.js与IE8一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆