HTML and CSS Reference
In-Depth Information
Figure 10-26
Final staff directory page
usernames and e-mail servers
are ren d ered in the correct order
You review your progress with Kate. As she scans through the code in the HTML file,
she's pleased to note that none of the e-mail addresses for the six staff members appears
in any readable form. By breaking the e-mail addresses into two parts (the userName and
emServer parts) and entering the text in reverse order, you have effectively hidden the
actual addresses from e-mail harvesting programs.
Commenting JavaScript Code
Kate is pleased to see how JavaScript can unscramble the e-mail addresses and present
them to users in a readable form. However, she is concerned that in the future, she might
forget how this program is designed to work. She would like you to add some comments
to the code you created.
Inserting Single-Line and Multiline Comments
Commenting your code is an important programming practice. It helps other people who
examine your code to understand what your programs are designed to do and how they
work. It can even help you in the future when you return to edit the programs you've
written and need to recall the programming choices you made. Comments can be added
to scripts as either single or multiple lines. The syntax of a single-line comment is
//ƒ commentƒtext
where commentƒtext is the JavaScript comment. Single-line comments can be placed
within the same line as a JavaScript command, making it easier to interpret each com-
mand in your code. The following is an example of a JavaScript statement that includes a
single-line comment:
document.write(emLink);ƒ//ƒwriteƒe-mailƒaddressƒtoƒtheƒWebƒpage
For more extended comments, you place the comment text on several lines using the
following structure:
/*
ƒƒƒcommentƒtextƒspanning
ƒƒƒseveralƒlines
*/
Search WWH ::




Custom Search