Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .