JavaScript: How to make cool hint or tooltip
Realy useful thing. No hints - no money. :)
Source code:
Source code:
<A href="javascript:void(0);" onmouseover="showhint(this, '$100 000 000')">money</A>
<STYLE>
.hintstyle {
position:absolute;
background:#EEEEEE;
border:1px solid black;
padding:2px;
}
</STYLE>
<SCRIPT>
var hintcontainer = null;
function showhint(obj, txt) {
if (hintcontainer==null) {
hintcontainer = document.createElement("div");
hintcontainer.className="hintstyle";
document.body.appendChild(hintcontainer);
}
obj.onmouseout = hidehint;
obj.onmousemove=movehint;
hintcontainer.innerHTML=txt;
}
function movehint(e) {
if (!e) e = event; //line for IE compatibility
hintcontainer.style.top = (e.clientY+document.documentElement.scrollTop+2)+"px";
hintcontainer.style.left = (e.clientX+document.documentElement.scrollLeft+10)+"px";
hintcontainer.style.display="";
}
function hidehint() {
hintcontainer.style.display="none";
}
</SCRIPT>

THX:-)
Posted by Patryk from Poland on June 20, 2009 at 11:50 PM GMT+03:00 #
Cool code, much better then similar offers in 600-900 lines.
Posted by myaddr on November 02, 2009 at 07:36 PM GMT+03:00 #