<script type="text/javascript">
var tip={$:function(ele){
if(typeof(ele)=="object")
return ele;
else if(typeof(ele)=="string"||typeof(ele)=="number")
return document.getElementById(ele.toString());
return null;
},
mousePos:function(e){
var x,y;
var e = e||window.event;
return{x:e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,y:e.clientY+document.body.scrollTop+document.documentElement.scrollTop};
},
start:function(obj){
var self = this;
var t = self.$("details");
obj.οnmοusemοve=function(e){
var mouse = self.mousePos(e);
t.style.left = mouse.x + 10 + 'px';
t.style.top = mouse.y - 60 + 'px';
t.innerHTML = obj.getAttribute("tips");
t.style.display = '';
}
obj.οnmοuseοut=function(){
t.style.display = 'none';
}
}
}
var tip={$:function(ele){
if(typeof(ele)=="object")
return ele;
else if(typeof(ele)=="string"||typeof(ele)=="number")
return document.getElementById(ele.toString());
return null;
},
mousePos:function(e){
var x,y;
var e = e||window.event;
return{x:e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,y:e.clientY+document.body.scrollTop+document.documentElement.scrollTop};
},
start:function(obj){
var self = this;
var t = self.$("details");
obj.οnmοusemοve=function(e){
var mouse = self.mousePos(e);
t.style.left = mouse.x + 10 + 'px';
t.style.top = mouse.y - 60 + 'px';
t.innerHTML = obj.getAttribute("tips");
t.style.display = '';
}
obj.οnmοuseοut=function(){
t.style.display = 'none';
}
}
}
</script>
html的实现代码
<a href="javascript:void(0)" οnmοuseοver="tip.start(this)" tips="'.$mac.'"><font color="blue">显示文本框</font></a>