How to find out where the alert is raised from?
You can overwrite alert
, and create an Error
for the stack trace:
var old = alert;alert = function() { console.log(new Error().stack); old.apply(window, arguments);};
You can monkeypatch the alert to do so:
//put this at the very top of your page:window.alert = function() { throw("alert called") }
How about wrapping the alert
?
window.original_alert = alert;alert = function (text) { // check the stack trace here do_some_debugging_or_whatever(); // call the original function original_alert(text);}
This should be cross-browser.