在javascript中禁用内置函数(警报) [英] Disable a built-in function in javascript (alert)
本文介绍了在javascript中禁用内置函数(警报)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
简单:我想禁用/覆盖 alert()
。
Simple: I want to disable/overwrite alert()
.
我可以这样做吗?
更重要的是,这样做是对的吗?
More importantly, is it right to do this?
严格模式怎么样?
推荐答案
是的,您可以禁用或覆盖 alert()
。不,这是不对的,除了在一些奇怪和有限的情况下。
Yes, you can disable or overwrite alert()
. No, it's not right to do it, except in some bizarre and limited situations.
禁用:
window.alert = function() { };
覆盖:
window.alert = function(text) { /* do something */ };
这篇关于在javascript中禁用内置函数(警报)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文