It is because of such errors on foreign bank pages that a large number of users are lost and they are afraid to use the bank's online banking, resulting in heavy losses.
So a mistake that is not allowed to occur in terms of user experience and company strength, even if it does not affect the use and does not offend users, Script House has always been committed to improving better code for everyone, so here We will sort out some commonly used codes and how to use them. We hope that everyone will support us more and more in the future and let us develop together.
The first type: Script House also uses it
How to use: Just add the above code to the head area of your error webpage.
The second type: It is aimed at the page that sometimes cannot be browsed due to some script errors. This problem is very serious, resulting in a large loss of users, or the inability to view you at all.
This is not a simple script error problem. The main reason is that the author of the code has not considered perfection. It must be modified carefully. But if you really don’t know how, then use such code
try...catch can test for errors in your code. The try section contains the code that needs to be run, while the catch section contains the code that runs when an error occurs.
Syntax:
try
{
//Run code here
}
catch(err)
{
//Handle errors here
}
Note: try... catch uses lowercase letters. Capital letters will go wrong.
Example 1
The following example was originally used to display the "Welcome guest!" message when the user clicks the button. However, alert() in the message() function is mistakenly written as adddlert(). At this time the error occurred:
]
We can add try.. .catch statement so that more appropriate action can be taken when an error occurs.
The following example re-modifies the script using try...catch statements. The error occurred because alert() was written by mistake. But this time, the catch section catches the error and handles it with a prepared piece of code. This code will display a custom error message to inform the user of what happened.
If you need to introduce external Js, you need to refresh to execute
]
Example 2
[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]
More related For js fault tolerance processing, you can refer to the following two articles: JavaScript Try...Catch statement
JavaScript fault tolerance exception handling