Connecting Tech Pros Worldwide Help | Site Map

Disable/Suppress alerts?

  #1  
Old July 19th, 2006, 03:25 AM
nick
Guest
 
Posts: 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.

  #2  
Old July 19th, 2006, 03:35 AM
Kevin Darling
Guest
 
Posts: n/a

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

  #3  
Old July 19th, 2006, 03:55 AM
nick
Guest
 
Posts: n/a

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
  #4  
Old July 19th, 2006, 05:45 AM
Jim Land
Guest
 
Posts: n/a

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.
  #5  
Old July 19th, 2006, 11:25 AM
Richard Cornford
Guest
 
Posts: n/a

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