Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize full fault tolerance and browser automatic maximization by JavaScript

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to achieve full fault tolerance and browser automatic maximization of JavaScript". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to achieve full fault tolerance and browser automatic maximization of JavaScript".

Immediate handling of error codes

The Javascript code we compiled sometimes has some errors due to our carelessness, so that users

When browsing, a tiresome error frame pops up. How to deal with this situation? Here are two kinds of constant

See method:

(1) full fault tolerance

That is, when users browse the page with the error code, they ignore all the errors. The code is as follows:

< script >

Function killerr () {

Return true

}

_ window.onerror=killerr

< / script >

Although it can cover up the error and avoid popping up the error prompt box, the program has not been executed correctly. Here is another

How to deal with it.

(2) feedback error messages

That is, when an error code occurs, the feedback window that we designed in advance pops up automatically, so that the user only needs to simplify

With a single click of the mouse, you can send the feedback to your designated mailbox, of course, the contents of the feedback window.

The design can be modified at will. The code is as follows:

< script >

Function errorinfo ()

{

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

Errorwin.[ XSS _ clean] ('< title > script error report < / title > < center > this page

Please notify < a href= "mailto:lhy@cenpok.net" > if you found an error in running the script. < / a >

Administrator. < br > < form > < input type= "button" value= "close window" onCli

Ck= "window.close ()" > < / form > < / center >')

Errorwin.document.close ()

Errorwin.document.bgColor= "# ffffff"

Return true

}

_ window.onerror=errorinfo

< / script >

Optimize the browsing window

With this code, when the user opens your page, the browser window automatically expands to the maximum available space

(not full screen), isn't it very professional?

The following code is placed between < head > < / head >:

< script language= "Javascript" >

Share To

Development

© 2024 shulou.com SLNews company. All rights reserved.

12
Report