阻止javascript警告框

问题描述:

我正在使用广泛的javascript工作。我正在处理的代码也依赖于其他 big javascript库。事情就是在这些库中的某个地方弹出一些警告框。

I'm working on a website using extensively javascript. The code I'm working on also rely on other big javascript libs. The thing is that somewhere in these libraries, some alert box are poping.

我想知道是否有某种方法可以动态禁用javascript警告框 并稍后重新启用。

I was wondering if there are some way to disable the javascript alert box on the fly and re-enable it later.

谢谢

将旧的 alert 函数保存到变量。

Save the old alert function, to a variable.

_alert=alert;

然后将旧的提醒设置为 null 自定义函数。

And then set the old alert to either null a custom function.

alert=function(){};
/*or*/
alert = null;

简单地恢复原始版本的 alert 反向步骤1.

To restore the original version of alert simply reverse step 1.

alert=_alert