Other Properties & Uses

Moving on... Other objects have properties too. Like the page's background color. In HTML, the attribute for the background color is background-color, but in JavaScript, it is backgroundColor. (Notice the lack of a hyphen and the capitalization.)

To create a link that will change the window's background color using an onMouseOver event, I'll have to think this through:

HTML file: Displayed by browser:
<body>

<A HREF="http://www.htmlgoodies.com" target="_blank"
onMouseOver="document.bgColor='pink';
    return true">Click Here</A>

</body>
Click Here

* Note: The newest JavaScript code to do this, is by using document.body.style.backgroundColor. (It's kinda long, isn't it...?) Anyway, my experiments still show that there is no difference, whether I use return true/false or completely remove the code. So, I still am seeing why I should ever use it at all!

Back   Table of Contents   Next