HTML and CSS Reference
In-Depth Information
<!-- <![CDATA[
// ]]> -->
Save this file as documentwrite.html and view it in the browser. The text should display,
as shown in Figure 14.10. If the text does not display, open the Error Console and correct
any errors that appear.
Figure 14.10
Firefox displaying
JavaScript can be seen in the source code. To confirm this, use the View, Page Source
menu commands to see the source code. Close the source code window when you have
finished viewing the code.
Why would I use document.write when I can just type the XHTML
code by itself?
You wouldn't use document.write to generate your Web page if you could just type the
XHTML code by itself. You would use document.write in conjunction with other techniques.
For instance, you might use JavaScript to detect the time of day, and if it is before noon use
document.write to write “Good morning” to the document. If it is afternoon, write “Good
afternoon” to the document, and if it is after 6:00 p.m., write “Good evening” to the document.
14.6 Events and Event Handlers
As the user is viewing a Web page, the browser detects mouse movement and events.
Events are actions taken by the Web page visitor, such as mouse clicks, page loads, or
form submissions. For instance, when you move your mouse pointer over a hypertext
link, the browser detects a mouseover event. Table 14.1 lists a few of the events and
their descriptions.
Search WWH ::

Custom Search