title: How to detect where JavaScript alert is coming from?
body: <p>I am trying to debug a very complex IE Intranet application. I am getting an alert with a custom message stating that an exception has occurred. I would like to find out more information about this exception as the message is not very helpful.</p>
  
  <p>There is a master page which contains a lot of iFrames (and .htc files if that makes a difference) so I don't think that I can try and <a href="https://stackoverflow.com/a/4867114/79835">hijack window.alert</a>. My last resort will be to try my luck with a file search.</p>
  
  <p>Using IE 8, is there anyway I can detect where this alert is coming from? The ideal solution would be to somehow create a "breakOnAlert" function which inserts a debbuger statement at the correct alert location.</p>
  
  <p><strong>To clarify:</strong> The master page contains many iframes and I believe that the error+alert is coming from one of these. Each iframe is an aspx page (sometimes with dynamic html/javascript from the user) and contains inline and external JavaScript. Before posting I did try overriding <em>alert</em> in my page (a child page inside an iframe) but it didn't work. <strike>I am assuming that</strike> It doesn't work as each iframe has their own window object so they each have their own version of <em>alert</em>. For this to work I would need to find all iframes and override it for each one, something which I think would be very complicated to do. In the IE developer tools I can see a huge amount of script files (inline and external), so it would be very difficult to manually look for the alerts in there.</p>