the simple ajax tooltip based on prototype --koma
On begining this code.you should add script reference that is"prototype.1.3"
var tip = Class.create();
tip.prototype={
initialize:function(obj){
this.main = obj;
this.id = obj.id;
this.main.onmouseover = this.showTip.bind(this);
this.main.onmouseout = this.hideTip.bind(this);
},
showTip:function(){
var div = document.createElement("div");
div.style.width = "56px";
div.style.backgroundColor = "#ff0066";
div.style.height = "24px";
div.style.position = "absolute";
div.style.left = new Position.cumulativeOffset(this.main)[0]+55;
div.style.top = new Position.cumulativeOffset(this.main)[1]+20;
div.innerHTML = this.desc();
div.id = this.id+"_";
document.body.appendChild(div);
},
hideTip:function(){
Element.remove(this.id+"_");
},
desc:function(){
var result;
var option = {
parameters:"s=s",
method:"get",
onSuccess:function(transport){
var rp = transport.responseText;
result = rp;
}
};
var ajax = new Ajax.Request("ajax.aspx",option);
return result;
}
};
window.onload=function(){
var o = document.getElementById("bt");
var tips = new tip(o);
}