Tutorials - JavaScript - Lesson 2 - The Document Command
With HTML, any text that you want to appear on the page must be in the <body>
tags, however, in JavaScript this command is replaced by the document
command.
JavaScript itself is embedded into the HTML document, and is generally
placed within the <head> tags, but it
can be placed and executed anywhere on the page. Here is an example:
<html>
<head>
<title>document object example</title>
<script language = "JavaScript">document.write('hello
world');</script>
</head>
<body></body>
</html>
You can see that there is no text in the HTML page's <body>
tags. The JavaScript command is placing the text in brackets on the page.
That's not very exciting is it? But JavaScript can do a lot more, in Tutorial
3, we'll look at the "window" command.
back
|