Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Having just done a bit of reading on this, it looks like onerror can also be attached to the window object. See:</p> <p><a href="http://www.javascriptkit.com/javatutors/error.shtml" rel="nofollow noreferrer">http://www.javascriptkit.com/javatutors/error.shtml</a></p> <p>According to that page, you can pass in msg, url and linenumber arguments:</p> <pre><code>window.onerror=function(msg, url, linenumber){ alert('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+linenumber) return true } </code></pre> <p>Not sure on the browser support for this, but thanks for bringing it to my attention!</p> <p><strong>Update:</strong> didn't do anything in Safari 4 (apart from logging an error in firebug as per usual), but shows the alert in Firefox 3.6 Beta 5. Error test at <a href="http://www.javascriptkit.com/javatutors/errortest2.htm" rel="nofollow noreferrer">http://www.javascriptkit.com/javatutors/errortest2.htm</a></p> <p><strong>Update 2:</strong> done a test with the following:</p> <p>index.html:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; window.onerror=function(msg, url, linenumber){ alert('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+linenumber) return true } &lt;/script&gt; &lt;script type="text/javascript" src="js.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>js.js: (stupid name, i know!)</p> <pre><code>document.write('hi there' </code></pre> <p>Result in FF 3.6 Beta 5:</p> <p><img src="https://twitpic.com/show/full/x758d.png" alt="Result"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload