Home  >  Article  >  Web Front-end  >  JS - javascript fault tolerance handling code

JS - javascript fault tolerance handling code

高洛峰
高洛峰Original
2016-11-17 11:54:581853browse

1. Phenomenon description
When an error occurs in the execution of the javascript code on the page, the browser will display an error message.
JS - javascript fault tolerance handling code

2. Shield js errors

Sometimes after our project goes online, we need to let the browser ignore js errors. You can add the following code in the script tag, then the page will no longer display error prompts.

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

Note: Doing this just ignores the error message. If an error occurs in js, the execution of the following js will still be blocked.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn