我正在处理opencart项目的项目,该项目即将完成。当用户单击打开的其他选项卡时,我现在有一个问题。Java正在显示警报ERROR消息。这是因为网速慢或者页面加载不正确。我仍然想删除该消息。有什么方法可以删除或修复它。请帮助我。这是链接
要阻止这个恼人的警报出现在您的商店中,只需在您的网站标题中包含以下脚本即可。
<script>
(function() {
var new_alert = window.alert;
window.alert = function(str) { //str variable return content which is passed to be shown in alert
str1 = str.replace(/('r'n|'n|'r)/gm,""); //Removing line break from string
if (str1 !="error"){ //show alert only if content is not equal to 'error'
new_alert(str);
}
else{
// do nothing
}
};
})();
</script>
如果您想知道它的作用:它只是替换了javascript的默认警报功能,当其内容为"错误"时不显示警报。
使用简单地覆盖警报
<script>window.alert = function() {};</script>