It shows that you are unregistered. Please register with us by clicking Here
![]() |
|
![]() |
![]() | Register - FAQ - Today's Posts - New Posts - Support - Search | ![]() |
|
|
#1 (permalink) |
|
Member
Join Date: Jul 2006
Age: 48
Posts: 45
|
The alart function is a very useful means of analyzing errors. You can use it at any point in a script to probe objects and variables to see if they contain the data you expect. For example, if you have a function that has several conditional branches, you can add an alert within each condition to find out which is being executed:
function checkAge(years) { if (years < 13) { alert ('less then 13'); } else if (years >= 13 && years <= 21) { alert ('13 to 21'); } else { alert ('older'); } } Maybe the value for years is not coming back as a number, like it should. You could add to the start of your script an alert that tests the variable to see what type it is: function checkAge(years) { alert(typeof years); : : } In theory, you can put any amount of information in an alert dialog, although a very long string of data could create such a wide dialog that some of the information would be clipped or outside the window. You can avoid this by formatting the output with the escape characters, such as \n for a break line. |
|
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What HTTP error is generated when there is an error in an ASP page? | agaba175 | ASP | 0 | 08-05-2006 08:25 PM |