Whats wrong with this (javascript noob)

Wiseguy2001

2[H]4U
Joined
Nov 28, 2001
Messages
3,470
Hi Guy, today is my first day in the wonderful world of javascript. It was going well - its quite easy to pick up.

Below is the code I'm trying to get to work but I keep getting an error (tried 3 browsers). Copied it from the text book exactly!
Code:
office at <A HREF="MAILTO:[email protected]" onMouseOver="window.status='We will reply to your inquiry within 24 hours!';retern true" onMouseOut="window.status='';return true">[email protected]</A>

Error msg says ';' Expected. But thats in the middle of window.status. Just dont get it.
 
I'm sorry to go off-topic here, but I really don't think you should be doing what you're trying to do here. In general, changing the status text is something that people just don't do these days unless they're trying to annoy their users. You particularly should not do it on a link, since it obscures what the link goes to. You really, really should not do it on a mailto link, when you may be forcing your user to open their mail client unexpectedly.

Anyway, all that said, I'm glad you got it working, at least. Now you should lowercase your tags, Javascript events, and the "MAILTO" label. These will make your markup more compatible with newer standards.

Here's how this code would look if I were using it (which I wouldn't ;)):
HTML:
office at <a href="mailto:[email protected]" onmouseover="javascript:window.status='We will reply to your inquiry within 24 hours!';" onmouseout="javascript:window.status='';">[email protected]</a>
 
HorsePunchKid i agree 100%

I'm doing a course in basic web design and following a related text book which is showing its age (2001 :( ), all the tags are in uppercase and theres a few errors. but to be fair they are pushing w3.org like its the bible.

The reason for the onmouseover and onmouseout with the link is to get the hang of event handlers with javascript.

This just prepping me for my next course which is client side scripting.
 
Just an FYI... :)

The core lanaguage definition is ECMAScript. JavaScript and JScript are implementaitons of that language specification.
 
Just out of curiosity, can JS give a tooltip? That'd be a good alternative to changing the status bar text without adding more text to the screen unnecessarily.
 
PopeKevinI said:
Just out of curiosity, can JS give a tooltip? That'd be a good alternative to changing the status bar text without adding more text to the screen unnecessarily.

You can add the title attribute to any tag in HTML/XHTML, almost every browser renders it as a tooltip. For example:
HTML:
office at <a href="mailto:[email protected]" title="We will reply to your inquiry within 24 hours!">[email protected]</a>
 
Back
Top