Javascript 我可以覆盖IE8中的原型函数吗?

Javascript 我可以覆盖IE8中的原型函数吗?,javascript,internet-explorer-8,Javascript,Internet Explorer 8,我编写了以下代码,用于在调用Node.prototype.appendChildobj时提醒消息 var _appendChild = Node.prototype.appendChild; Node.prototype.appendChild = function(object){ alert("append"); return _appendChild.apply(this,[object]); ; }; 而且它在IE8中不起作用 我读过这个链接,其

我编写了以下代码,用于在调用Node.prototype.appendChildobj时提醒消息

var _appendChild = Node.prototype.appendChild;
Node.prototype.appendChild = function(object){
    alert("append");
    return _appendChild.apply(this,[object]);           ;
};  
而且它在IE8中不起作用

我读过这个链接,其中的答案是原型函数不能在IE中被重写

但我仍然想问,是否有任何工作可以做我想做的


谢谢

您不能扩展IE8中的节点,但可以扩展HTMLDocument.prototype和Element.prototype


您不能扩展IE8中的节点,但可以扩展HTMLDocument.prototype和Element.prototype

谢谢kennebec

最后我发现我无法实现它,因为它是在怪癖模式下运行的。。。 我写了一个别人可能感兴趣的例子

var elementPrototype = typeof HTMLElement !== "undefined"
        ? HTMLElement.prototype : Element.prototype;

var _appendChild = elementPrototype.appendChild; 

elementPrototype.appendChild = function(content){
    //Do what you want-----

    alert("Append Child!");

    //---------------------
    return _appendChild(content);
}
谢谢kennebec

最后我发现我无法实现它,因为它是在怪癖模式下运行的。。。 我写了一个别人可能感兴趣的例子

var elementPrototype = typeof HTMLElement !== "undefined"
        ? HTMLElement.prototype : Element.prototype;

var _appendChild = elementPrototype.appendChild; 

elementPrototype.appendChild = function(content){
    //Do what you want-----

    alert("Append Child!");

    //---------------------
    return _appendChild(content);
}

谢谢,但在我的IE8中,它表明HTMLDocument和元素都没有定义。它们在IE8中受支持吗?谢谢,但在我的IE8中,它表明HTMLDocument和元素都没有定义。IE8支持它们吗?