We've used a number of styles in the book to help you understand what's going on. We've used the important words style to flag up new or important subjects. Screen Text is used to indicate anything you'd see on the screen, including URLs. New blocks of code are in this code foreground style:
<html> <body> <script language="JavaScript"> var myCalc = 1 + 2; document.write("The calculated number is " + myCalc); </script> </body> </html> If we're amending a script, perhaps adding in a new line or making changes to an existing one, then we use the code background style for the code that you've already seen together with the foreground style to highlight the new code:
<html> <body> <script language="JavaScript"> var userEnteredNumber = prompt("Please enter a number",""); var myCalc = 1 + userEnteredNumber; var myResponse = "The number you entered + 1 = " + myCalc; document.write( myResponse); </script> </body> </html> To talk about code within text we use this code in text style, which is also used for file names like MyFirstPHP.php
A Note About Code FormattingWe've tried to make the code as easy to read as possible. This does mean that there is sometimes whitespace in the scripts that would break the code if you used it exactly as it is printed. For example, this JavaScript code:
output+="<a href=\""+getPageName(pages[i][j])+".html\" class=\"page\" title=\""+pages[i][j]+"\">"; will look like this in the book:
output+="<a href=\""+getPageName(pages[i][j])+".html\" class=\"page\" title=\""+pages[i] [j]+"\">"; The code in the download is without the whitespace. |