Home > Web Front-end > JS Tutorial > Usage and example analysis of window.onerror()_javascript skills

Usage and example analysis of window.onerror()_javascript skills

WBOY
Release: 2016-05-16 15:17:28
Original
2096 people have browsed it

onerror syntax uses

onerror has three input parameters by default:

•msg: error message
•url: The file where the error is located
•line: The line of code where the error is located, integer
window.onerror = function(msg, url, line){ // some code };
For the form of , parameters can be obtained through arguments[0], arguments[1], and arguments[2] in sequence.

What we most commonly use in js is js fault tolerance

window.onerror=function(){return true;}
Copy after login

Basic Features
You can prevent the browser from displaying error messages by setting returnValue=true or returning true directly. But it will not prevent the debugging box from popping up by script debuggers.
Onerror will only be triggered by runtime errors, not by syntax errors.

Onerror can be triggered in the following three ways:

• Runtime errors such as invalid object reference or security restriction
• Download errors such as pictures
•In IE9, failure to obtain multimedia data will also trigger
The

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template