Show JavaScript Error

[Total: 0    Average: 0/5]

This file shows how to create a javascript routine that can execute upon a javascript error.

Head Code:

<script type="text/javascript">
var errorCount = 0
var email="web-help@js-examples.com"
function reportError(msg,url,line) {
  var w = window.open("","error"+errorCount++,"resizable,status,width=625,height=400")
  var d = w.document
  d.write('<div align=center>')
  d.write('<font size=7 face="helvetica"><B>')
  d.write('opps..... A JavaScript Error Has Occurred!')
  d.write('</b></font><br><hr size=4 width="80%">')
  d.write('<form action="mailto:'+email+'" method=post')
  d.write('enctype="text/plain">')
  d.write('<font size=3>')
  d.write('<i>Click the "Report Error" button to send a bug report.</I><br>')
  d.write('<input type="submit" value="Report Error">&nbsp;&nbsp;')
  d.write('<input type="button" value="Dismiss" onClick="self.close()">')
  d.write('</div><div align=right>')
  d.write('<br>Your name <i>(optional)</i>: ')
  d.write('<input size=42 name="name" value="">')
  d.write('<br>Error Message: ')
  d.write('<input size=42 name="message" value="'+msg+'">')
  d.write('<br>Document: <input size=42 name="url" value="'+url+'">')
  d.write('<br>Line Number: <input size=42 name="line" value="'+line+'">')
  d.write('<br>Browser Version: ')
  d.write('<input size=42 name="version" value="'+navigator.userAgent+'">')
  d.write('<div></font></form>')
  d.close()
  return true
}
self.onerror=reportError
</script>

Body Code:


Times Viewed: 6

Leave a Reply

Your email address will not be published. Required fields are marked *