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.
Note that, because
window is the implicit top-level object, we could leave it off and just write
alert("The page is loading"). And, in fact, this is the way it is usually done.
write() method of the
document object is a child of
window, so we could write
window.document.write('some text'), but again,
window is implicit.
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.
body object is a property of the
document object, the
style object is a property of the
body object, and
backgroundColor is a read-write property of the
style object. To understand what's going on, it can be useful to read the dot notation from right to left: "The
style of the
body of the
button elements use the
onclick on-event handler to catch click events. When the user clicks on a