我知道在IE8中你可以扩展Element Interface
所以你可以抽象attachEvent / detachEvent,比如......
if (!window.addEventListener) {
// Internet Explorer 8 provides access to its 'Element' Interface…
window.Element.prototype.addEventListener = function(type, listener, useCapture) {
this.attachEvent('on' + type, listener);
}
window.Element.prototype.removeEventListener = function(type, listener, useCapture) {
this.detachEvent('on' + type, listener);
}
}
...但我不确定如何在IE7中实现这一点,虽然我听说它可以通过.htc文件实现?
能用任何方式告诉我究竟是怎么回事?
答案 0 :(得分:0)
Prototype.js,AFAIK,通过将其方法直接添加到元素(无论何时通过$()
调用)而不是原型来解决这个问题,而这种方法不起作用。
如果你正在寻找一个黑客来让这项工作看看:http://blog.motane.lu/2007/09/20/elementprototype-in-ie/