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:
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〉:
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.