The Software Tools
What your first script will do
If you encounter an error in your first attempt at loading this document into your browser, go back to the text editor and check the lines of the script section, looking carefully at each line. There may be a single character out of place, a lowercase letter where an uppercase one belongs, or a quote or parenthesis missing. Make necessary repairs, switch to your browser, and click Reload.
To see how dynamic the script in test.html is, go back into the text editor and replace the word “world” with “Friend “ Save, switch, and reload to see how the script changes the text in the document. Feel free to substitute other text for the quoted text in the document. Write()statement. Or, add more text with additional document.write()statements. Always be sure to save, switch , and reload to see the results of your handiwork.
Some browser do not support the <script> …</script> tags. If your document is to be rendered with such browsers, enclose the script code between these tags in an HTML comment, so that the script text does not get displayed as part of the web page.
- Always include a semicolon at the end of a statement to terminate the statement. This notation clarifies where one statement ends and the next statements begin
This line uses the browser’s document object, which represents document the browser is currently displaying. The document object allows a script programmer to specify text to display in the HTML document.
An object resides in the computer’s memory and contains information used by the script. The term object normally implies that attributes (data) behaviours (methods) are associated with the object. The object’s methods use the attribute’s data to perform useful actions for the client of the object. (i.e. the script that calls the methods) A method may require additional information (arguments) to perform its action. This information is enclosed in parentheses after the name of the method in the script. In above line, the document object’s write. In method is called to write a line of markup in the HTML document.
- Forgetting the ending </script> tag for a script may prevent the browser from interpreting the script properly and many prevent the HTML document from loading properly.