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/p/2526624.html