Wednesday, 2018-10-24
Stay Close
Site menu
Catalog categories
Computers [3]
Business [3]
Travel [3]
Technology [3]
Sports [3]
Health [3]
Arts [3]
Home & Garden [3]
Entertainment [3]
Tag Board
Our poll
Rate my site
Total of answers: 82
Main » Articles » Computers

How to catch errors in JavaScript

part of being a developer is not only efficient JavaScript code that is running the way you want to, but also ensure that your script code to catch errors. It is not always easy to catch JavaScript errors - especially when they are caused by outdated browser or by providing incorrect information to a script. Fortunately, there are some circumstances may include in their scripts to address script .

catching errors in the JavaScript

Introduce onerror event. JavaScript onerror the case when running a browser encounters an error in a JavaScript function. But it is not effective by itself. You need to tell the browser what to do once the error occurs with a defined role .

first. Definition of a function is a simple matter to tell a Web browser that there is a role, naming the roles and functions to end .

Tell a web browser that there is a role with the word "role . Follow up with a unique name for the function, a pair of brackets of the parameters and then left curly bracket. End of the function with a right curly brackets on their own line. Example: UhOh function () {}

Replace "UhOh" with his own label .

definition Place commands that you want to run when the "UhOh () is called later in a script. Make sure these commands are their own lines between left and right curly bracket curly bracket. You can give a command to display items such as an alert box, a confirmation box or a new website .

Copy and paste into your website code below (under the previous code): onerror = ErrorFound (UhOh ()) In the above example, the JavaScript code tells the browser to start a feature called "ErrorFound", and run the UhOh () function as a way to address the mistakes it finds.

replace the value in the past with their own codes having stuck in your website.

This article is written by Writing Articles.
Category: Computers | Added by: stayclose (2009-01-13)
Views: 588 | Comments: 1 | Rating: 0.0/0 |
Total comments: 1
1  
it help me alot

Name *:
Email *:
Code *:
Login form
Search
Site friends
Download StayClose Toolbar

Download StayClose Toolbar

 



( )
Privacy
 
Copyright MyCorp © 2018