Here's a possible answer...

Run your mouse over this link

Here's the script that did it:

<SCRIPT LANGAUGE="javascript">

<!-- Hide from browsers that do not understand Javascript function goodbyedate() { var d = new Date(); var h = d.getHours(); var m = d.getMinutes(); var t = h + ':' + m + ' '; alert ("Leaving so soon? It's only " + t + "."); } // end hiding --> </SCRIPT> </HEAD> <body bgcolor="FFFFCC" onUnload="goodbyedate()"> <A HREF="assign_10.html" onMouseOver="window.status= 'Hey ' +navigator.appName+ ' user - click here!'; return true" onMouseOut="window.status= 'You should leave ' +document.location+ ' right away.'; return true">Run your mouse over this link</A> </BODY>


The function in the head commands creates the time by calling for the hours and minutes. That function is then called for in the onUnLoad command in the BODY of the HTML document. The time variable is then placed inside an alert command.

The onMouseOver and onMouseOut commands are basically the same as was shown in the tutorial except I called for the "navigator.appName" in the onMouseOver and then called for the "document.location" in the onMouseOut. The trick to this long line is where to place all the single and double quotes. Notice the pattern above: each of the "window.status" commands is surrounded in double quotes. The text bits inside then use single quotes. Just be careful to end all single and double quotes and you shouldn't have much trouble.

Close this window to return to JavaScript Primer #1