Div形式的title显示JS代码【原】
这个其实并不是原创,是从别人网站上扒下来的哈·····
感觉很漂亮,所以就·····呵 ····
把这个JS加到你的项目中·····
1

2
var pltsPop=null;3
var pltsoffsetX = 10; // 弹出窗口位于鼠标左侧或者右侧的距离;3-12 合适4
var pltsoffsetY = 15; // 弹出窗口位于鼠标下方的距离;3-12 合适5
var pltsPopbg="#FFFFEE"; //背景色6
var pltsPopfg="#111111"; //前景色7
var pltsTitle="";8
document.write('<div id=pltsTipLayer style="display: none;position: absolute; z-index:10001"></div>');9
function pltsinits()10


{11
document.onmouseover = plts;12
document.onmousemove = moveToMouseLoc;13
}14
function plts()15


{ var o=event.srcElement;16

if(o.alt!=null && o.alt!="")
{o.dypop=o.alt;o.alt=""};17

if(o.title!=null && o.title!="")
{o.dypop=o.title;o.title=""};18
pltsPop=o.dypop;19
if(pltsPop!=null&&pltsPop!=""&&typeof(pltsPop)!="undefined")20

{21
pltsTipLayer.style.left=-1000;22
pltsTipLayer.style.display='';23
var Msg=pltsPop.replace(/\n/g,"<br>");24
Msg=Msg.replace(/\0x13/g,"<br>");25
var re=/\{(.[^\{]*)\}/ig;26
if(!re.test(Msg))pltsTitle="<font color=#ffffff>中国移动校讯通欢迎您!</font>";27

else
{28
re=/\{(.[^\{]*)\}(.*)/ig;29
pltsTitle=Msg.replace(re,"$1")+" ";30
re=/\{(.[^\{]*)\}/ig;31
Msg=Msg.replace(re,"");32
Msg=Msg.replace("<br>","");}33
var attr=(document.location.toString().toLowerCase().indexOf("list.asp")>0?"nowrap":"");34
var content =35
'<table style="FILTER:alpha(opacity=90) shadow(color=#bbbbbb,direction=135);" id=toolTipTalbe border=0><tr><td width="100%"><table class=tableBorder7 cellspacing="1" cellpadding="0" style="width:100%">'+36
'<tr id=pltsPoptop ><th height=18 valign=bottom class=th1 ><b><p id=topleft align=left><font color=#ffffff>↖</font>'+pltsTitle+'</p><p id=topright align=right style="display:none">'+pltsTitle+'<font color=#ffffff>↗</font></b></th></tr>'+37
'<tr><td "+attr+" class=tablebody7 style="padding-left:14px;padding-right:14px;padding-top: 6px;padding-bottom:6px;line-height:135%">'+Msg+'</td></tr>'+38
'<tr id=pltsPopbot style="display:none"><th height=18 valign=bottom class=th1><b><p id=botleft align=left><font color=#ffffff>↙</font>'+pltsTitle+'</p><p id=botright align=right style="display:none">'+pltsTitle+'<font color=#ffffff>↘</font></b></th></tr>'+39
'</table></td></tr></table>';40
pltsTipLayer.innerHTML=content;41
toolTipTalbe.style.width=Math.min(pltsTipLayer.clientWidth,document.body.clientWidth/2.2);42
moveToMouseLoc();43
return true;44
}45
else46

{47
pltsTipLayer.innerHTML='';48
pltsTipLayer.style.display='none';49
return true;50
}51
}52

53
function moveToMouseLoc()54


{55
if(pltsTipLayer.innerHTML=='')return true;56
var MouseX=event.x;57
var MouseY=event.y;58
//window.status=event.y;59
var popHeight=pltsTipLayer.clientHeight;60
var popWidth=pltsTipLayer.clientWidth;61
if(MouseY+pltsoffsetY+popHeight>document.body.clientHeight)62


{63
popTopAdjust=-popHeight-pltsoffsetY*1.5;64
pltsPoptop.style.display="none";65
pltsPopbot.style.display="";66
}67
else68


{69
popTopAdjust=0;70
pltsPoptop.style.display="";71
pltsPopbot.style.display="none";72
}73
if(MouseX+pltsoffsetX+popWidth>document.body.clientWidth)74


{75
popLeftAdjust=-popWidth-pltsoffsetX*2;76
topleft.style.display="none";77
botleft.style.display="none";78
topright.style.display="";79
botright.style.display="";80
}81
else82


{83
popLeftAdjust=0;84
topleft.style.display="";85
botleft.style.display="";86
topright.style.display="none";87
botright.style.display="none";88
}89
pltsTipLayer.style.left=MouseX+pltsoffsetX+document.body.scrollLeft+popLeftAdjust;90
pltsTipLayer.style.top=MouseY+pltsoffsetY+document.body.scrollTop+popTopAdjust;91
return true;92
}93
pltsinits();94

95

然后在引用的页面上加上样式,当然你也可以写在CSS里面哈····
1
<style>2

.tableBorder7{
}{width:800;solid; background-color: #000000;}3

TD{
}{font-family: 宋体;font-size: 12px;line-height : 15px ;}4

th{
}{background-color: #f7f7f7;color: #000000;font-size: 12px;font-weight:bold;}5

th.th1{
}{background-color: #333333;}6

td.TableBody7{
}{background-color: #B1EA45;}7
</style>8

9

搞定·····
欢迎您访问本BLOG作者官方网站!!! http://www.2zhichan.cn 程序交换网

浙公网安备 33010602011771号