Using The JavaScript "onerror" Event


This script uses the "onerror" event to catch any JavaScript errors, which may have occurred on a page.

In the example below, I use an error in the message function. As you can see below I have inserted the following:

notalert("Welcome to!")

What I should have done is:

alert("Welcome to!")

Thus the error message is displayed using the "onerror" event..

If you decide you want to use or alter this script to suit your needs, please give your support and leave a link to this site thanks.






Script Source


<script type="text/javascript">
var txt=""

function handleErr(msg,url,l)
txt="There was an error on this page.\n\n"
txt+="Error: " + msg + "\n"
txt+="URL: " + url + "\n"
txt+="Line: " + l + "\n\n"
txt+="Click OK to continue.\n\n"
return true

function message_alert()
notalert("Welcome to!")

// Script by



Please let me know if this script was helpful to you.