我已经有一组函数用于扩展文档(即绑定/解除绑定)。所以,我可以做的东西,如:document.bind('load',someAction,{})
为iframes扩展文档DOM
但如果我这样做不工作:$('some_iframe').contentWindow.document.bind(...)
而显然,$('some_iframe').contentWindow.document.prototype
不存在。
编辑: 以下是代码故障:
//the eggplant library
eggp = {
extend: function(dest, source){
for(var prop in source)
dest.prototype[prop] = source[prop];
return dest;
},
//other functions below...
bind{},
unbind{}
}
//extend the DOM
eggp.extend(Document, eggp);
//extending the iframe document DOESN'T WORK
eggp.extend(someiframe.contentWindow.document, eggp);
我检查,看看是否someiframe.contentWindow.document
是不确定的,但它返回object HTMLDocument
您可以提供扩展文档的代码吗? – 2010-07-29 00:38:30
与实际问题没有直接关系,但是当您承认自己基本上正在复制Prototype时,为什么要使用自己的库? – 2010-07-29 00:54:22
我使用我自己的库有很多原因:我不能让自己在不理解的情况下使用别人的代码;我无法理解jQuery或原型,所以我开始写我自己的;我正在设计图书馆的功能,用于我正在编程的网络建筑软件......等。 我并不完全复制原型,因为我无法弄清楚他们在做什么(因为我不是在JavaScript中足够好)。所以,我想我只是在做任何事情。 – Azmisov 2010-07-29 04:06:03