The JavaScript onerror method is the first thing to handle error in JavaScript. This error event is called on the window object whenever any exception occurs on the page.
There are three pieces of information to identify the exact error:
Example of JavaScript onerror:
<html> <head> <script type="text/javascript"> window.onerror = function (msg, url, line) { console.log("Message : " + msg ); console.log("url : " + url ); console.log("Line number : " + line ); } </script> </head> <body> <p>Click the following button:</p> <form> <input type="button" value="Click Here" >Read Also: JavaScript Strict mode
Alternatively, you can use an onerror method to display an error message if there is any problem in loading an image.
<img src="image.jpg" onerror="alert('Loading failed')" />
In today's competitive academic world, students are constantly juggling multiple responsibilities, from preparing for exams…
There is more to handbags than being accessories; they add to a look and tell…
Every constructed premise has a certain survival time. A constructed house or commercial property has…
In a world where digital presence is paramount, the question isn't whether you should do…
Over the years, people have experimented with various methods to maintain healthy and beautiful hair.…
Your brand more than developing an attractive and creative logo and infectious motto. It's the…