Handling ErrorsWhile you may have years of experience working with computers, it's a good bet that many of your site's visitors won't. Consequently, you'll want to give them meaningful error messages instead of the technobabble that most browsers return if they object to something the user does. Script 3.13 shows how to use JavaScript's try/throw/catch commands to produce a friendly, useful error message. We've built this into a simple square root calculator. Script 3.13. Use this script to have JavaScript handle errors gracefully.
To handle errors gracefully:
Figure 3.10. If bad data was entered, let the user know.
Tip
|