(转) 鼠标经过时显示 DIV 提示框的 JS 码

//这里不用多说了,JS代码
<script language="JavaScript">
//----------------------写HTML代码----------------------
var changdi="<table style='margin:0 0 0 0;border:solid 1px #009933;background:#ffffff''><tr><td align='center' vlign='middle'><img src='../website/image/tips.jpg' width=50 height=50></td><td align='center' vlign='middle'><font color='green' size='6'>这里写你需要显示的东西,也重新写这个变量里面所有的HTML</font></td></tr></table>";
//------------------------------------------------------
var isIE = document.all?true:false;
function overlib(tipcontent)
{
customdiv
= document.getElementById("overDiv");
customdiv2
= document.getElementById("overDiv2");


customdiv.innerHTML
= tipcontent;
var tleft
=document.body.scrollLeft+window.event.clientX;
var ttop
=document.body.scrollTop+window.event.clientY;
if(document.body.clientWidth < 300)
{
customdiv.style.left
= 2;
customdiv2.style.left
= 2;

}
else if (tleft > document.body.clientWidth-200)
{
customdiv.style.left
= tleft-175;
customdiv2.style.left
= tleft-175;

}
else
{
customdiv.style.left
= tleft + 10;
customdiv2.style.left
= tleft + 10;

}
if(document.body.clientHeight < 100)
{
customdiv.style.top
= 25;
customdiv2.style.top
= 25;

}
else if(ttop > document.body.clientHeight -55)
{
customdiv.style.top
= ttop - 55;
customdiv2.style.top
= ttop - 55;

}
else
{
customdiv.style.top
= ttop + 10;
customdiv2.style.top
= ttop + 10;
}
customdiv2.style.width
=customdiv.clientWidth;
customdiv2.style.height
=customdiv.clientHeight;

customdiv.style.visibility
= 'visible';
customdiv2.style.visibility
= 'visible';


}
function nd()
{
customdiv
= document.getElementById("overDiv");
customdiv2
= document.getElementById("overDiv2");
customdiv.style.width
=0;
customdiv.style.height
=0;
customdiv.style.visibility
= 'hidden';
customdiv2.style.visibility
= 'hidden';
}
function b(v)
{
window.status
=v
};

</script>


//这里可以放在网页的任何地方,一个IFRAME,一个DIV,组合起来可以遮挡SELECT
<div id="overDiv" style="position:absolute; visibility:hidden;z-index:100;padding:0 0 0 0;background:#FDFEF9;text-align:left;font-size:12px;">
</div>
<iframe id="overDiv2" src="" scrolling="no" frameborder="no"style="position:absolute; visibility:hidden;z-index:99;filter: Alpha(style=0,opacity=0) "> </iframe>

//鼠标悬停调用
onMouseOver="return overlib(changdi)" onMouseOut="return nd();"

转载于:https://www.cnblogs.com/s021368/articles/1327408.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值