[英]how to stop showing alert box after overriding alert function
I use this code for overriding alert function but after i use this to show my custom alert box it show both of them how can i stop the default alert box ? 我使用此代码重写警报功能,但在使用此代码显示我的自定义警报框后,它同时显示了两者如何停止默认警报框? use preventDefault();
使用preventDefault(); ?
? where?
哪里?
(function(event) {
var proxied = window.alert;
window.alert = function(str) {
bootbox.alert(str);
return proxied.apply(this, arguments);
};
})();
Your code for overriding the default alert function
, contains another alert function bootbox.alert(str);
您用于覆盖默认
alert function
代码包含另一个警报功能bootbox.alert(str);
due to which it goes into infinite loop showing too much recursion error.
因此,它进入无限循环,显示
too much recursion error.
You could try below proxy pattern for overriding. 您可以尝试使用以下代理模式进行覆盖。
(function(event) {
var proxied = window.alert;
window.alert = function(str) {
//Your code here
proxied.apply(this, arguments);
return true;
};
})();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.