Connecting Tech Pros Worldwide Forums | Help | Site Map

Disable/Suppress alerts?

nick
Guest
 
Posts: n/a
#1: Jul 19 '06
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.


Kevin Darling
Guest
 
Posts: n/a
#2: Jul 19 '06

re: Disable/Suppress alerts?



nick wrote:
Quote:
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

nick
Guest
 
Posts: n/a
#3: Jul 19 '06

re: Disable/Suppress alerts?


Thanks actually I just thought of and tried the same thing!

Kevin Darling wrote:
Quote:
nick wrote:
Quote:
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
Jim Land
Guest
 
Posts: n/a
#4: Jul 19 '06

re: Disable/Suppress alerts?


"Kevin Darling" <kdarling@basit.comwrote in news:1153277025.075127.308280
@m73g2000cwd.googlegroups.com:
Quote:
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.
Richard Cornford
Guest
 
Posts: n/a
#5: Jul 19 '06

re: Disable/Suppress alerts?


Kevin Darling wrote:
<snip>
Quote:
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.


Closed Thread