21 April 2007

Make link from a span


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<script type="text/javascript">
//
// Handling MouseOver & MouseOut Events

var elementId;
var StateValue = false;

function isChanged(/*As String*/ elementID, /*As Boolean*/ stateValue)
{
elementId = document.getElementById(elementID);

if (StateValue == false) // mouse is over
{
StateValue = true;
// set new values
elementId.style.color = "#FF0000";
elementId.style.cursor = "hand";
elementId.style.borderBottomStyle = "dashed";
elementId.style.borderBottomColor = "#FF0000";
elementId.style.borderBottomWidth = "1px";

}
else // mouse is out
{
StateValue = false;
// restore to initial values
elementId.style.color = "";
elementId.style.cursor = "";
elementId.style.borderBottomStyle = "";
elementId.style.borderBottomColor = "";
elementId.style.borderBottomWidth = "";
}
return StateValue;
}

</script>


<style type="text/css" media="screen">
span
{
color: #0066FF; /* Blue */
}
</style>
</head>
<body>
<span id="Span1" onmouseout="isChanged(this.id, false);"
onmouseover="isChanged(this.id, true);">Hover me!</span>
</body>
</html>

No comments: