The Document Object (Part Two)
The document Title Property
You can also reset the title of the web page. Change you alert code to this:
alert(document.title = "Now I've changed it")
The equals sign in there doesn't actually mean equals. It means "assign the value". So what we're saying is "Assign the value of 'Now I've changed it' to the title of the document."
Any direct text that you type after the "assignment operator" (the equals sign) needs to go inside double quotes.
Load up your new code in your browser, and watch what happens. First, you'll get an alert box:
Netscape/Mozilla Alert Box
Internet Explorer Alert Box
But that's not the only thing that happens. If you look at the very top of your browser, the title should have change from "The title of this web page" to "Now I've changed it." Here's the changed version in the two most popular browsers:
Now that you're an expert with alert boxes, here's a little exercise.