Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to stop an alert box being popped up by the browser using Javascript, as I find it bothersome. Is there any way to do this? Perhaps an addon, or script?

share|improve this question
1  
Is this an alert box on a specific site, or do you want to stop any alert boxes appearing in your browser? Which browser are you using? –  Paul Nov 29 '11 at 13:11
    
The browser is mobile safari and it is an alert box on a specific site. –  vikram Nov 29 '11 at 14:23
add comment

2 Answers

One can interpret the question in two ways:

1.I want to use javascript to stop alert boxes

You can override the alert function so it'll do nothing:

window.alert = function () {}

Unfortunately, the usual fiend (IE) will not accept this, as alert is special voodoo-magic to it and not a regular function.

2.I want to stop alert boxes spawned by javascript

You can't turn off specific features. You either disable javascript, or deal with it.

share|improve this answer
    
Zirak, Y U NO GREASEMONKEY? –  rlemon Nov 29 '11 at 13:52
    
Hi All,Thanks for your comments. The real scenario is like i have a line of code in javascript window.location=some url. now i want to stop any type of alert box generated due to problem in url and execute the code silently. –  vikram Nov 29 '11 at 14:26
add comment

in Firefox and Chrome this option is built in (after the first popup, if consecutive popups are your concern)

enter image description here enter image description here

or if you use FireFox you can install greasemonkey and this user script

OR if you are the webpage owner and you want to disable alerts on your own site (for what reason I don't know)

window.alert = function(){}; will likely do it (not sure about IE.. but thats a start).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.