HTML and CSS Reference
In-Depth Information
Figure 10-28
Reporting a load-time error in the Firefox error console
A run-time error occurs after a script has been successfully loaded and is being
executed by a browser. In a run-time error, the mistake occurs when the browser cannot
complete a line of code. One common source of a run-time error is mislabeling a vari-
able name. For example, the line of code
document.write(emlink);
in the showEM() function would result in the run-time error shown from the Internet
Explorer browser in Figure 10-29.
Figure 10-29
Reporting a run-time error in internet explorer
The mistake in this line of code is that there is no variable named emlink in the
showEM() function—the variable name should be emLink (recall that variable names are
case sensitive). When a browser attempts to write the contents of the emlink variable
to the Web document, it discovers that no such variable exists and reports the run-time
error. When a JavaScript interpreter catches a run-time error, it halts execution of the
script and displays an error message indicating the location where it was forced to quit.
Logical errors are free from syntax and structural mistakes, but result in incorrect
results. A logical error is often the hardest to fix and sometimes requires you to meticu-
lously trace every step of your code to detect the mistake. Suppose you had incorrectly
entered the line of code to create the emLink variable, placing the server name before
the username, as follows:
varƒemLinkƒ=ƒemServerƒ+ƒ“@”ƒ+ƒuserName;
In this case, a browser would display the list of e-mail addresses as shown in Figure 10-30.
 
Search WWH ::




Custom Search