JavaScript: Completely fault tolerant

Source: Internet
Author: User

Real-time error code processing
The JavaScript code we compile sometimes has some errors due to our negligence, so that users
The annoying error prompt framework will pop up during browsing. How can this problem be solved? Which of the following statements about the community? Nbsp;
See method:

(1) completely fault tolerant

That is, all errors are ignored when you browse pages with error code. The Code is as follows:

<Script> 〉

Function killerr (){

Return true

}

Window. onerror = killerr

</Script> 〉

Although it can cover up errors and avoid pop-up error prompts, but the program is still not correctly executed, the following introduces another
Processing Method.

(2) feedback error information

That is, when the error code appears, the pre-designed feedback window is automatically displayed, so that users only need
Click the mouse to send the feedback to your specified mailbox.
You can modify the design as needed. The Code is as follows:

<Script> 〉

Function errorinfo ()

{

Errorwin = window. open ("", "", "width = 20, height = 120 ″)

Errorwin.doc ument. write ('<title> Script Error Report </title> <center> feedom.net
A script running error was found, please <a href = "mailto: lhy@cenpok.net"> notice </a> 〉
Administrator. <Br> <form> <input type = "button" value = "Close Window" onCli
Ck = "window. close ()"> </form> </center> 〉′)

Errorwin.doc ument. close ()

Errorwin.doc ument. bgColor = "# ffffff ″

Return true

}

Window. onerror = errorinfo

</Script> [transferred from www.bitsCN.com]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.