CouchApp 和 Internet Explorer 8 中的 jQuery
我正在尝试 http://couchapp.org/page/what-is-couchapp 中的一个简单示例,在 Internet Explorer 8 上,它只是抛出“对象不支持此函数或方法”,并且指向的部分是“forEach”方法。我使用 jQuery 1.4.2 附带的 CouchBase 服务器 1.0.2。当我用1.6版本替换jquery.js时没有任何变化。 jquery.couch.app.js 中已经存在 forEach 的补丁。我能做点什么吗?
(最终,我想让基于 jQuery 的 jsTree 在 IE 上运行,但 IE 甚至不加载我本地保存的演示页面。)
<!DOCTYPE html>
<html>
<head><title>Tiny CouchApp</title></head>
<body>
<h1>Tiny CouchApp</h1>
<ul id="databases"></ul>
</body>
<script src="/_utils/script/jquery.js"></script>
<script src="/_utils/script/jquery.couch.js"></script>
<script>
$.couch.allDbs({
success : function(dbs) {
dbs.forEach(function(db) {
$("#databases").append('<li><a href="/_utils/database.html?'+db+'">'+db+'</a></li>');
});
}
});
</script>
</html>
提前致谢。
编辑
通过更改 forEach 来映射并将以下函数添加到 jquery.couch.app.js,这个小应用程序确实可以工作。
if (!Array.prototype.map)
{
Array.prototype.map = function(fun/*, thisp*/)
{
"use strict";
var len = this.length;
if (typeof fun != "function")
throw new TypeError();
var res = new Array(len);
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in this)
res[i] = fun.call(thisp, this[i], i, this);
}
return res;
};
}
I am trying out a simple example from http://couchapp.org/page/what-is-couchapp, on Internet Explorer 8 and it just throws the 'object doesn't support this function or method' and the part that is pointed to is the 'forEach' method. I use CouchBase server 1.0.2 that comes with jQuery 1.4.2. There is no change when I replace the jquery.js with the 1.6 version. There already exists a patch for forEach in jquery.couch.app.js. Is there anything that I can do about this ?!
(Ultimately, I want to get the jQuery based jsTree working on IE, but IE doesn't even load the demo page that I saved locally.)
<!DOCTYPE html>
<html>
<head><title>Tiny CouchApp</title></head>
<body>
<h1>Tiny CouchApp</h1>
<ul id="databases"></ul>
</body>
<script src="/_utils/script/jquery.js"></script>
<script src="/_utils/script/jquery.couch.js"></script>
<script>
$.couch.allDbs({
success : function(dbs) {
dbs.forEach(function(db) {
$("#databases").append('<li><a href="/_utils/database.html?'+db+'">'+db+'</a></li>');
});
}
});
</script>
</html>
Thanks in advance.
EDIT
By changing the forEach to map and adding the following function to jquery.couch.app.js, the tiny app does work.
if (!Array.prototype.map)
{
Array.prototype.map = function(fun/*, thisp*/)
{
"use strict";
var len = this.length;
if (typeof fun != "function")
throw new TypeError();
var res = new Array(len);
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in this)
res[i] = fun.call(thisp, this[i], i, this);
}
return res;
};
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论