The return true Code

These extra two words are supposed to have quite a bearing on what will happen when the event takes place. Maybe in the old days! This does not seem to be effective with today's browsers. Learning about this piece of code seems to be a waste of time!

But I'll try to bear with this. In this example, when the cursor rolls over the link, an URL appears in the status bar. The event has happened. When the cursor moves off the link, the URL is overwritten by the specified text in the script, because I wrote return true, which means "do it if the event (onMouseOver) happened." Well, that works in Internet Explorer, but not Firefox or Chrome.

Below, I am using the exact same script as the example above, but this time I typed return false. Watching the status bar as the mouse rolls over the link, I had not expected the overwriting of the URL with my specified text, but it did happen... In each of my preferred browser, there is no difference in all, whether I used true or false!

HTML file: Displayed by browser:
<body>

<A HREF="http://www.htmlgoodies.com" target="_blank"
onMouseOver="window.status='Go to the Goodies Home Page';
    return false">Click Here</A>

</body>
Click Here

I even removed the return true/false code entirely from the script, and still got the same result, as if I used return true. I thought for sure that the specified text would be totally ignored, thinking that the script has no permission whatsoever to display it. I was wrong.

So, my question now is: WHAT IS THE PURPOSE OF RETURN TRUE/FALSE?

Back Table of Contents Next