Advertisement
here2share

$ JS Alert On Error

Jan 11th, 2023
776
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.onerror = function(msg, url, line, col, error) {
  2.   // Note that col & error are new to the HTML 5 spec and may not be
  3.   // supported in every browser.  It worked for me in Chrome.
  4.   var extra = !col ? '' : '\ncolumn: ' + col;
  5.   extra += !error ? '' : '\nerror: ' + error;
  6.   alert("Error: " + msg + "\nurl: " + url + "\nline: " + line + extra);
  7.   var suppressErrorAlert = true;
  8.   // If you return true, then error alerts (like in older versions of
  9.   // Internet Explorer) will be suppressed.
  10.   return suppressErrorAlert;
  11. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement