mouse_on_title.js
程序员文章站
2022-06-19 19:54:56
复制代码 代码如下:var pltspop=null; var pltsoffsetx = 5; ...
复制代码 代码如下:
var pltspop=null;
var pltsoffsetx = 5; // 弹出窗口位于鼠标左侧或者右侧的距离;3-12 合适
var pltsoffsety = 5; // 弹出窗口位于鼠标下方的距离;3-12 合适
var pltspopbg="#ffffff"; //背景色
var pltspopfg="#880000"; //前景色
var pltstitle="";
document.write('<div id=pltstiplayer style="display: none;position: absolute; z-index:10001"></div>');
function pltsinits()
{
document.onmouseover = plts;
document.onmousemove = movetomouseloc;
}
function plts()
{ var o=event.srcelement;
if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
pltspop=o.dypop;
if(pltspop!=null&&pltspop!=""&&typeof(pltspop)!="undefined")
{
pltstiplayer.style.left=-20;
pltstiplayer.style.display='';
var msg=pltspop.replace(/\n/g,"<br>");
msg=msg.replace(/\0x13/g,"<br>");
var re=/\{(.[^\{]*)\}/ig;
if(!re.test(msg))pltstitle="";
else{
re=/\{(.[^\{]*)\}(.*)/ig;
pltstitle=msg.replace(re,"$1")+" ";
re=/\{(.[^\{]*)\}/ig;
msg=msg.replace(re,"");
msg=msg.replace("<br>","");}
var attr=(document.location.tostring().tolowercase().indexof("")>0?"nowrap":"");
var content =
'<table style="filter:alpha(opacity=90) shadow(color=#6f6f6f,direction=135);" id=tooltiptalbe ><tr><td width="100%"><table class=tdr cellspacing="0" cellpadding="0" border=0 style="width:100%">'+
'<tr id=pltspoptop ><th height=25 valign=bottom class=tdr><p id=topleft align=left>'+pltstitle+'</p><p id=topright align=right style="display:none">'+pltstitle+'</th></tr>'+
'<tr><td "+attr+" class=bg_tdr style="padding-left:14px;padding-right:14px;padding-top: 6px;padding-bottom:6px;line-height:135%">'+msg+'</td></tr>'+
'<tr id=pltspopbot style="display:none"><th height=25 valign=bottom class=tdr><p id=botleft align=left>'+pltstitle+'</p><p id=botright align=right style="display:none">'+pltstitle+'</th></tr>'+
'</table></td></tr></table>';
pltstiplayer.innerhtml=content;
tooltiptalbe.style.width=math.min(pltstiplayer.clientwidth,document.body.clientwidth/2.2);
movetomouseloc();
return true;
}
else
{
pltstiplayer.innerhtml='';
pltstiplayer.style.display='none';
return true;
}
}
function movetomouseloc()
{
if(pltstiplayer.innerhtml=='')return true;
var mousex=event.x;
var mousey=event.y;
//window.status=event.y;
var popheight=pltstiplayer.clientheight;
var popwidth=pltstiplayer.clientwidth;
if(mousey+pltsoffsety+popheight>document.body.clientheight)
{
poptopadjust=-popheight-pltsoffsety*1.5;
pltspoptop.style.display="none";
pltspopbot.style.display="";
}
else
{
poptopadjust=0;
pltspoptop.style.display="";
pltspopbot.style.display="none";
}
if(mousex+pltsoffsetx+popwidth>document.body.clientwidth)
{
popleftadjust=-popwidth-pltsoffsetx*2;
topleft.style.display="none";
botleft.style.display="none";
topright.style.display="";
botright.style.display="";
}
else
{
popleftadjust=0;
topleft.style.display="";
botleft.style.display="";
topright.style.display="none";
botright.style.display="none";
}
pltstiplayer.style.left=mousex+pltsoffsetx+document.body.scrollleft+popleftadjust;
pltstiplayer.style.top=mousey+pltsoffsety+document.body.scrolltop+poptopadjust;
return true;
}
pltsinits();
上一篇: Android获取窗体信息的Util方法
下一篇: 赖尿虾你吃过吗,赖尿虾的做法有哪些呢?
推荐阅读