I think the window.onerror handler will provide you with such functionality where you can notify erorr, url and line number,
Demo
Note. Make sure the window.onerror function is in a separate script tag, as shown below. Any error registered in the error console will be warned.
<script> window.onerror = function(msg, url, lineNo) { alert(msg + '\n' + url + '\n Line No: ' + lineNo); } </script> <script> document.getElementById('test').asd = 123; </script> <script> var s = [{]}; </script> <script> throw "Custom Error"; </script>
Selvakumar arumugam
source share