UNPKG

catch-all-errors

Version:

Catch all JavaScript errors and post them to your server

31 lines (27 loc) 893 B
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta content="width=device-width, initial-scale=1" name="viewport"> <script src="https://chr15m.github.io/catch-all-errors/catch-all-errors.min.js" data-post-url="example-api.php" data-continuous></script> </head> <body> <script> window.onload = function() { var el = document.getElementById("testInput"); var barf = function() { throw new Error('borked=' + el.value); }; if (el.addEventListener) { el.addEventListener('change', barf, true); } else { el.attachEvent('onchange', barf); } // trigger an error at startup blee(); } </script> <p>To trigger an error, type something into the text field and hit [Enter].</p> <input type="text" id="testInput" name="testInput"> </body> </html>