Connecting Tech Pros Worldwide Help | Site Map

Disable/Suppress alerts?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 19th, 2006, 02:25 AM
nick
Guest
 
Posts: n/a
Default Disable/Suppress alerts?

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, 02:35 AM
Kevin Darling
Guest
 
Posts: n/a
Default 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, 02:55 AM
nick
Guest
 
Posts: n/a
Default 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, 04:45 AM
Jim Land
Guest
 
Posts: n/a
Default 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, 10:25 AM
Richard Cornford
Guest
 
Posts: n/a
Default 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.


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.