JavaScript: Full fault tolerance and automatic browser maximization

Source: Internet
Author: User
Tags error code return window
javascript| Browser | fault-tolerant | Maximizing error code instant processing
Our JavaScript code is sometimes flawed by our negligence, so that the user
How do you handle this situation when browsing pops up with annoying error-tip frames? Here are two common
See method:

(1) Complete fault tolerance

That is, when the user browses the page containing the error code, ignore all the errors. The code is as follows:

〈script〉

function Killerr () {

return True

}

Window.onerror=killerr

〈/script〉

Although it can cover up errors, avoid pop-up error balloon, but the program still does not execute correctly, the following describes another
Processing methods.

(2) Feedback error message

That is, when the error code appears, automatically pop-up our pre-designed feedback window, the purpose is to user only Jane
A single click of the mouse can send feedback to your designated mailbox, of course, the content of the feedback window we
Can modify the design arbitrarily. The code is as follows:

〈script〉

function ErrorInfo ()

{

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

Errorwin.document.write (′〈title〉 script error report 〈/title〉〈center〉 this page
Face found a script run error, please 〈a href=″mailto:lhy@cenpok.net″〉 notify 〈/a〉
Administrator. 〈br〉〈form〉〈input Type=″button″value=″ Closes the window ″oncli
Ck=″window.close () ″〉〈/form〉〈/center〉′)

Errorwin.document.close ()

Errorwin.document.bgcolor=″#ffffff″

return True

}

Window.onerror=errorinfo

〈/script〉

Optimizing the Browsing window

Using this code, when the user opens your page, the browser window automatically expands to the maximum available space
(not full screen), is not very professional?

The following code is placed between 〈head〉〈/head〉:

〈script language=″javascript″〉

〈!--function Winfix () {

if (document.layers) {

width=screen.availwidth-10;

height=screen.availheight-20;

} else {

var width=screen.availwidth-2;

var height=screen.availheight;

}

Self.resizeto (width, height);

Self.moveto (0, 0);

}

--〉

〈/script〉

The following code is placed in the 〈body〉tag:

〈body Onload=″winfix () ″〉

Related Article

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.