HTML and CSS Reference
In-Depth Information
If the line break occurs within a quoted text string, you can also break the string into
several distinct text strings placed over several lines by adding a plus symbol (+) at the
end of each line, as follows:
The + symbol used in this command combines several text strings into a single text
string. However, breaking a single statement into several lines is usually not recom-
mended because of the possibility of introducing errors into the code. It should be done
only with very long and complicated statements.
You can also write a long
text string to a Web page
by breaking the text string
into several document.
write() statements.
Supporting Non-JavaScript Browsers
For browsers that don't support scripts or that have their support for client-side scripts
disabled, you can specify alternative content using the noscript element
ƒƒƒ alternativeƒcontent
where alternativeƒcontent is the content a browser should display in place of
accessing and running the script. For example, the following code displays a text mes-
sage indicating that the page requires the use of JavaScript:
Browsers that support client-side scripts and have that support enabled ignore the
content of the noscript element. Note that the noscript element is not supported
under XHTML strict.
Working with Variables
Because you used a specific text string with the document.write() , the code did little
more than what you could have accomplished by entering the e-mail link directly into
an HTML tag. JavaScript is much more powerful and versatile when used in conjunction
with variables. A variable is a named item in a program that stores a data value—such as
a number or text string—or an object—such as a part of the Web document or browser.
Variables are useful because they can store information created in one part of a program
and use that information elsewhere. Variable values can also change as a program runs,
enabling the program to display different values under varying conditions.
Declaring a Variable
You introduce variables in your code by declaring them. Declaring a variable tells the
JavaScript interpreter to reserve memory space for the variable. To declare a variable you
use the var keyword
varƒ variable ;
Search WWH ::

Custom Search