我已经在 Windows XP SP3 的 IE7 和 IE8(所有兼容模式)和 Windows 7 Ultimate 的 IE8(所有兼容模式)上进行了测试,并且在两者上都以同样的方式失败。我正在运行最新的 HEADcouchapp http://github.com/couchapp/couchapp存储库。这在我的 OSX 10.6.3 开发机器上运行良好。我已经在 Windows 7 Ultimate 上使用 Chrome 4.1.249.1064 (45376) 和 Firefox 3.6 进行了测试,它们都工作正常。 OSX 10.6.3 上的 Safari 4 和 Firefox 3.6 也是如此
这是错误消息
网页错误详细信息
用户代理:Mozilla/4.0(兼容;
微星8.0; Windows NT 6.1;三叉戟/4.0;
SLCC2; .NET CLR 2.0.50727; .NET CLR
3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0) 时间戳:4 月 28 日星期三
2010 年 03:32:55 世界标准时间
消息:对象不支持此功能
属性或方法 行:159 字符:7
代码:0 URI:http://192.168.0.105:5984/test/_design/test/vendor/couchapp/jquery.couch.app.js http://192.168.0.105:5984/test/_design/test/vendor/couchapp/jquery.couch.app.js
这是“有问题的”代码,它在 Chrome、Firefox 和 Safari 上运行得很好。如果说失败就在启动线上qs.forEach()
从文件中jquery.couch.app.js http://github.com/couchapp/couchapp/blob/master/vendor/_attachments/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 规范中的函数,因此并非所有浏览器都支持它。
您可以在 MDC 上阅读相关内容:https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/forEach https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/forEach
在“兼容性”下,您将找到一个使 forEach() 可用的代码片段。
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() 应该可以工作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)