Disable/Suppress alerts?

N

nick

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.
 
K

Kevin Darling

nick said:
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
 
R

Richard Cornford

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top