JS控制提示信息(2)
从蓝色理想网站拷贝过来的代码。[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>可乐吧俱乐部</title>
<style>
body{font-family:Verdana, Tahoma, Arial, Helvetica, sans-serif; font-size:12px;color:#444;font-weight:normal;}
.tip-bg{position:absolute;top:-26px;left:-5px;background:url("http://case.blueidea.com/img/common/tip_bg.gif") no-repeat right top;font-weight:normal;}
.tip-bulb{background:url("http://case.blueidea.com/img/common/tip_bulb.gif") no-repeat left top;padding:4px 2px 10px 15px;white-space:nowrap;color:#000;line-height:100%;}
.tip-bg a{text-decoration: underline;color:#000;}
</style>
<script language="javascript">
function showTip(obj,txt){
//感谢坏梨编写该函数.
//obj.style.position="relative"
//obj.innerHTML="<div class=\"tip-bg\"><div class=\"tip-bulb\"> "+txt+" </div></div>"+obj.innerHTML
//obj.onmouseover=function(){this.getElementsByTagName ('div')[0].style.display='block'}
//obj.onmouseout=function(){this.getElementsByTagName ('div')[0].style.display='none'}
// -- edited by qhwa : check if already setted up
if(obj.init) return;
obj.init = function(){
var thisObj = this;
var str = thisObj.innerHTML;
thisObj.style.position = "relative";
var div = document.createElement("div");
div.className = "tip-bg";
div.innerHTML = "<div class=\"tip-bulb\"> " + txt + " </div>";
thisObj.insertBefore(div,thisObj.firstChild);
//thisObj.innerHTML = "<div class=\"tip-bg\"><div class=\"tip-bulb\"> " + txt + " </div></div>" + str;
thisObj.getElementsByTagName ('div')[0].style.display = 'none';
thisObj.showTip();
thisObj.onmouseover = thisObj.showTip;
thisObj.onmouseout = thisObj.hideTip;
}
obj.showTip = function(){
var thisObj = this;
clearTimeout(thisObj.timeout);
thisObj.timeout = setTimeout(function(){
thisObj.getElementsByTagName ('div')[0].style.display='block';
},200);
}
obj.hideTip = function(){
var thisObj = this;
clearTimeout(thisObj.timeout);
thisObj.getElementsByTagName ('div')[0].style.display='none'
}
obj.init();
}
</script>
</head>
<body>
<br><br><br>
<div onmouseover="showTip(this,'返回可乐吧俱乐部首页')"><a href="#"><img src="http://ry168.net/bbs/images/default/logo.gif" alt=""/></a></div>
</body>
</html>[/code]
页:
[1]
