Simple: I want to disable / overwrite alert() .
alert()
Can I do it?
More importantly, is this the right thing to do?
How about high security?
Yes, you can disable or overwrite alert() . No, this is wrong to do, except in some strange and limited situations.
Disable:
window.alert = function() { };
Redefinition:
window.alert = function(text) { /* do something */ };
Yes you can, it's your choice. You can also keep the original βwarningβ:
window.nativeAlert = window.alert; window.alert = function(val){console.log(val+' (alert disabled)');};
now the old warning can still be used: nativeAlert('something');
nativeAlert('something');