The onerror event of the window object
The onerror event of the window object
Defining the onerror event with a function that returns a value of true at the very top of your page suppresses all scripting errors on the page .
window.onerror=function(){
alert('An error has occurred!')
return true
}
window.onerror=function(msg, url, linenumber){
alert('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+linenumber)
return true
}
var errordialog=function(msg, url, linenumber){
var dialog=document.createElement("div")
dialog.className='errordialog'
dialog.innerHTML=' JavaScript Error: ' + msg +' at line number ' + linenumber +'. Please inform webmaster.'
document.body.appendChild(dialog)
return true
}
window.onerror=function(msg, url, linenumber){
return errordialog(msg, url, linenumber)
}
沒有留言:
張貼留言