Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tooltip help 1

Status
Not open for further replies.

link9

Programmer
Nov 28, 2000
3,387
US
Morning all --

I am in need of some help on creating an onMouseOver action for some links that would pop up some tooltip text to explain to a user of a webpage what clicking on the link will produce.

I'm opting away from the traditional html 'alt' text because it takes too long to pop up.

Can someone either post some example code or point me to a good place where I could find a good script?

I would like to be able to customize the size of the popup text box, colors -- all that.

Any input would be greatly appreciated.

Thanks
Paul Prewett
 
Here is a relatively simple way. You'd need to modify it for older browsers.

var keepTip=0;
var currentTip;

function showTip(myTipName){
currentTip = document.getElementById(myTipName);
document.onmousemove = tipSlide;
tipSlide();
}

function tipSlide(){
var xOffset = 10;
var yOffset = -20;


var myTip = currentTip;

myTip.style.left = event.x + body.scrollLeft + xOffset;
myTip.style.top = event.y + body.scrollTop - yOffset;
myTip.style.visibility='visible';


}

function hideTip(tipname){

if(!keepTip){
document.onmousemove="";
document.getElementById(tipname).style.visibility="hidden";

}
else{document.onmousemove="";}

}


Fully customizable using styles - just use a span for the tooltip, and call the functions like:

onMouseOut="hideTip('tip1')" onMouseOver="showTip('tip1') ondoubleclick="keepTip=false;hideTip('tip2')" "


The keepTip idea is just so you could keep it open for interactive data inside it if you wanted to. These tips follow the mouse once it is over the hotspot.
b2 - benbiddington@surf4nix.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top