HTML and CSS Reference
In-Depth Information
Figure 10-8
embedding a script element
script to write
content to the
Web document
3. Save your changes to the file and then reload mpl.htm in your Web browser. As
shown in Figure 10-9, the text of Catherine's e-mail address should appear in the
staff directory.
Figure 10-9
text generated by javascript
e-mail addre s s
inserted using
JavaScript
Trouble? Internet Explorer might display a yellow alert bar at the top of the
browser window with a warning that it has restricted access to active content for
security reasons. This is done to enable users to prevent their browsers from run-
ning unwanted scripts. To run the script, click the information bar and choose
Allow Blocked Content from the pop-up menu, and then click Yes in the dialog
box that follows.
Note that the placement of the script element tells the browser where to place the
new text. Because the script element is placed between the opening and closing <td>
tags, the text generated by the script is placed there as well. In more advanced JavaScript
programs you can direct your output to specific locations in the Web page document,
but that's beyond the scope of this tutorial.
The document.write() Method
In JavaScript, many commands involve working with objects in the Web page and
browser. An object is any item—from the browser window itself to a document displayed
in the browser to an element displayed within the document. Even the mouse pointer, the
window scrollbars, or a browser application itself can be treated as an object. A method
is a process by which JavaScript manipulates or acts upon the properties of an object. The
document.write() method, which you just used to display the e-mail text, is one of the
Search WWH ::




Custom Search