By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,582 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

Disable/Suppress alerts?

P: n/a
Is it possible to disable/suppress alert popups in javascript? I need
to write a function that will loop through a form's inputs and
"manually" fire their onchange events (if found). Some of those
functions could popup alert boxes which I'd like to be able to
temporarily suppress.

Thanks for any help.

Jul 19 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

nick wrote:
Is it possible to disable/suppress alert popups in javascript? I need
to write a function that will loop through a form's inputs and
"manually" fire their onchange events (if found). Some of those
functions could popup alert boxes which I'd like to be able to
temporarily suppress.
First, allow me to say "yuck" for any UI that uses alerts ;-) Second,
if you maintain the code, you could change all the alerts to your own
myAlert() function and then you can change its behavior in one place.

However, you can (at least in IE) also do this;

window.org_alert = window.alert; // save original function ptr
window.alert = null; // disable alerts

The second line disables alerts, but you can put them back later if
wished by:

window.alert = window.org_alert;

Luck!
Kev

Jul 19 '06 #2

P: n/a
Thanks actually I just thought of and tried the same thing!

Kevin Darling wrote:
nick wrote:
Is it possible to disable/suppress alert popups in javascript? I need
to write a function that will loop through a form's inputs and
"manually" fire their onchange events (if found). Some of those
functions could popup alert boxes which I'd like to be able to
temporarily suppress.

First, allow me to say "yuck" for any UI that uses alerts ;-) Second,
if you maintain the code, you could change all the alerts to your own
myAlert() function and then you can change its behavior in one place.

However, you can (at least in IE) also do this;

window.org_alert = window.alert; // save original function ptr
window.alert = null; // disable alerts

The second line disables alerts, but you can put them back later if
wished by:

window.alert = window.org_alert;

Luck!
Kev
Jul 19 '06 #3

P: n/a
"Kevin Darling" <kd******@basit.comwrote in news:1153277025.075127.308280
@m73g2000cwd.googlegroups.com:
However, you can (at least in IE) also do this;

window.org_alert = window.alert; // save original function ptr
window.alert = null; // disable alerts
And that doesn't work in FF... However,

window.alert = function(){return null;}; // disable alerts

works in IE and FF.
Jul 19 '06 #4

P: n/a
Kevin Darling wrote:
<snip>
window.alert = null; // disable alerts

The second line disables alerts, ...
<snip>

This disables the alters in the sense that any code that attempts to
call - alert( ... ); - will error-out. It is unlikely that getting code
to error-out whenever an alert is used is the desired outcome. Assigning
a harmless function (- function(){return;} - should be enough) would
probably be better.

Richard.
Jul 19 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.