Alex Rivera | Logout

Disable alert();

Asked 2010-12-08T13:54:35.067
41

Code that is generated on my page that I cannot control contains an alert. Is there a jQuery or other way to disable alert() from working?

The javascript that is being generated that I want to disable/modify is:

function fndropdownurl(val)
1317 { var target_url
1318 target_url = document.getElementById(val).value;
1319 if (target_url == 0)
1320 {
1321 alert("Please Select from DropDown")
1322 }
1323 else
1324 {
1325 window.open(target_url);
1326 return;
1327 }
1328 } 

I want to disable the alert on line 1321

Thanks

Edit
Report

2 Answers

9

You can try and make a new function function alert() { } , this is not going to do anything since is empty and will overwrite the existing one.

answered 2010-12-08T13:56:50.247
6

Try this:

alert("test");
alert = function(){};
alert("test");

The second line assigns a new blank function to alert, while not breaking the fact that it is a function. See: http://jsfiddle.net/9MHzL/

answered 2010-12-08T13:56:39.750

Your Answer