The SPAN Flag

I've covered this tag in the beginner's HTML course and am very familiar with it. I use it frequently, but never with a JavaScript event handler. SPAN is a delivery device, a platform that carries other HTML attributes and JavaScript commands to text, images, tables or whatever else you can think of to surround with this element. Here is the syntax to use it:

<SPAN JavaScript Event Handlers>Text on HTML Page</SPAN>

The following script introduces three new event handlers:

  1. onMouseDown -- This event happens when the mouse is held down on the text
  2. onMouseUp -- This event happens when the mouse is released after pressing on the text
  3. onDblClick -- This event happens when the mouse is double clicked on the text
HTML file: Displayed by browser:
<body>

<SPAN onMouseDown="window.status='Mouse Is Down'";
onMouseUp="window.status='Mouse Is Up'";
onDblClick="location.href='thanxalot.html'";>
Click on this text</SPAN>

</body>
Click on this text

This script works fine with IE, if running from the hard drive -- it remains to be seen if it runs online. I doubt that it will. Both Chrome and Firefox will not write to the status bar at all. However, the onDblClick event works good on all three browsers.

BackTable of ContentsNext