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>