faqts : Computers : Programming : Languages : JavaScript : Links

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

63 of 92 people (68%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I display text on mouseover a text link as it happens with ALT in IMG tag

Aug 30th, 2001 21:03
Tony Crosby, Kiran Gollapudi,


Well, to get exactly the same effect with a link as alt would with an 
image, you could simply put <a title="This is a Title" href="">Test</a>.
 The title tag is to a link as alt is to an image.
 But I'd preffer something more, even for pictures. That's why I wrote 
this script out just a few days ago, I havn't had a use for it because 
it uses innerText which unfortunatly turned out to reset the undo 
history of the document so I couldn't use it after I made it.
----------------------------------------------------------------------
<html>
<head>
<STYLE TYPE="text/css">
<!--
.AltMenu {border:1px #000000 solid; background:#EEEEEE; cursor:ne-
resize;}
.Alts {font:11px verdana, arial, san-serif; color:#000000;}
}
-->
</style>
<script>
function Show(tag){
object = document.getElementById(tag);
object.style.visibility = "visible";
}
function Hide(tag){
object = document.getElementById(tag);
object.style.visibility = "hidden";
}
function showHelp(TXT){
document.getElementById('Alt').style.left=event.clientX+10;
document.getElementById('Alt').style.top=event.clientY+10;
Show('Alt');
document.getElementById('Alt2').innerText=TXT;
}
</script>
</head>
<body>
<div id='Alt' class="Altmenu" style="position: absolute; top: 0; left: 
0; width: 103; visibility: hidden; height: 10">
<table border='0' cellspacing="0" width="105%" height="10">
<tr><td width="100%" height="10" bgcolor="#FFFFCC" valign="middle" 
align="left"><div id='Alt2' class="Alts" style="width: 105; height: 
19"></div></tr>
</table>
</div>
<a onmouseover="showHelp('This Is My Helpfull Information About This 
Link....');" onmouseout="Hide('Alt');" 
href="http://www.google.com">This is a test link</a>
</body>
</html>
 It's a pretty useful script in the sense that you can customize it 
quickly since there is very little code here, for instance you could 
add a few setTimeout's here and there to delay the description box like 
an alt description would. And I never got around to making sure the box 
doesn't float off the page for links that are right up against the 
edges of the screen.
 Tony Crosby