/* This script simply outputs "Hello, there!" to the browser. */ document.write("<p>Hello, there!</p>");
alert() method of the
window object. When the browser reads that line of code, it will pop up an alert box and will not continue processing the page until the user presses the
OK button. Once the user presses the button, the alert box disappears and the rest of the page loads.
write() method of the
Methods can take zero or more arguments separated by commas.
write() methods shown in the example above each take only one argument: the message to show or the HTML to write out to the browser.
span elements use the
bgColor property to a new color.
bgColor property of
document is deprecated, meaning it should not be used anymore. Instead,
document.body.style.backgroundColor should be used to change the background color of the page. However, we do not get to the
style property in this course, so we use
bgColor for learning purposes. In practice, you can substitute
window object is always the implicit top-level object and therefore does not have to be included in references to objects. For example,
window.document.write() can be shortened to
window.alert() can be shortened to just