搜索
您的当前位置:首页正文

js原型被重写的解决办法..

来源:小奈知识网

比如说 window.alert = function(){}

这样的话我们想用弹窗的话就会失效了..

如果还想用的话具体解决方法有二种

第一种:

自己家的不行了就去别人家借一个..

window.alert = function(){}

function alert(str){
    var iframe = document.createElement('iframe');
    document.body.appendChild(iframe)
    iframe.contentWindow.alert(str)
}

第二种(推荐):

只是覆盖了方法,去他老家找他..

window.alert = function(){}

function alert(str){
    window.constructor.prototype.alert.call(window  , str)
}

ok..这就又可以继续用了..

 

转载于:https://www.cnblogs.com/nano/archive/2012/05/30/2526624.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Top