阻止javascript警告框 [英] Block javascript Alert box

查看:73
本文介绍了阻止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

这篇关于阻止javascript警告框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆