Javascript: Full fault tolerance and automatic maximization of browser windows

Source: Internet
Author: User
Some errors may occur due to our negligence when compiling JavaScript code,
As a result, the annoying error prompt framework is displayed during browsing. How can this problem be solved? The following describes two common methods:
------------------------------------------------------------------
I. Full Fault Tolerance
That is, when a user browses a page containing error code, all errors are ignored. The Code is as follows:

<SCRIPT>
Function killerr (){
Return true
}
Window. onerror = killerr
</SCRIPT>

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

Ii. Feedback of error messages
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 follows:

<SCRIPT>
Function errorinfo ()
{
Errorwin = Window. Open ("", "", "width = 20, Height = 120 ")
Errorwin.doc ument. Write ('<title> Script Error Report </title> <center> this page
A script running error was found, please <a href = "mailto: admin@siyizhu.com"> notification </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>

3. Optimized browsing window
With this code, the browser window will automatically expand to the maximum available space when the user opens your page.(Non-full screen)Isn't it very professional?
Run the following code between

<Script language = "JavaScript">
Self. moveTo (0, 0)
Self. resizeTo (screen. availwidth, screen. availheight)
</SCRIPT>

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.