Assignment 006B

JavaScript document.write

As you write your JavaScript code, please remember that JavaScript is not as forgiving as HTML. If you code something wrong, your Web page generates an error. Be patient and keep these things in mind when coding JavaScript:

JavaScript is a scripting language that uses objects. For example, your browser window is an object. We can refer to this object via JavaScript by using "window."

The browser window contains other objects, such as the document object. You can refer to the document object by using "window.object." The following is a method (action) of the document object. This method is called by using the following code:

window.document.write();

 

Here's the code to dynamically write the first two sentences of this Web page:

<script language="javascript" type="text/javascript">
window.document.write("<p>I am using Javascript to write the opening to this page. This text has been created by using JavaScript window.document.write.</p>");
</script>