Div形式的title显示JS代码

这个其实并不是原创,是从别人网站上扒下来的哈·····

感觉很漂亮,所以就·····呵 ····

把这个JS加到你的项目中·····

  1. var pltsPop=null;
  2. var pltsoffsetX = 10;   // 弹出窗口位于鼠标左侧或者右侧的距离;3-12 合适
  3. var pltsoffsetY = 15; // 弹出窗口位于鼠标下方的距离;3-12 合适
  4. var pltsPopbg="#FFFFEE"//背景色
  5. var pltsPopfg="#111111"//前景色
  6. var pltsTitle="";
  7. document.write('<div id=pltsTipLayer style="display: none;position: absolute; z-index:10001"></div>');
  8. function pltsinits()
  9. {
  10.     document.onmouseover   = plts;
  11.     document.onmousemove = moveToMouseLoc;
  12. }
  13. function plts()
  14. var o=event.srcElement;
  15.     if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
  16.     if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
  17.     pltsPop=o.dypop;
  18.     if(pltsPop!=null&&pltsPop!=""&typeof(pltsPop)!="undefined")
  19.     {
  20. pltsTipLayer.style.left=-1000;
  21. pltsTipLayer.style.display='';
  22. var Msg=pltsPop.replace(//n/g,"<br>");
  23. Msg=Msg.replace(//0x13/g,"<br>");
  24. var re=//{(.[^/{]*)/}/ig;
  25. if(!re.test(Msg))pltsTitle="<font color=#ffffff>中国移动校讯通欢迎您!</font>";
  26. else{
  27.    re=//{(.[^/{]*)/}(.*)/ig;
  28.    pltsTitle=Msg.replace(re,"$1")+" ";
  29.    re=//{(.[^/{]*)/}/ig;
  30.    Msg=Msg.replace(re,"");
  31.    Msg=Msg.replace("<br>","");}
  32.    var attr=(document.location.toString().toLowerCase().indexOf("list.asp")>0?"nowrap":"");
  33.        var content =
  34.       '<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%">'+
  35.       '<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>'+
  36.       '<tr><td "+attr+" class=tablebody7 style="padding-left:14px;padding-right:14px;padding-top: 6px;padding-bottom:6px;line-height:135%">'+Msg+'</td></tr>'+
  37.       '<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>'+
  38.       '</table></td></tr></table>';
  39.        pltsTipLayer.innerHTML=content;
  40.        toolTipTalbe.style.width=Math.min(pltsTipLayer.clientWidth,document.body.clientWidth/2.2);
  41.        moveToMouseLoc();
  42.        return true;
  43.        }
  44.     else
  45.     {
  46.     pltsTipLayer.innerHTML='';
  47.       pltsTipLayer.style.display='none';
  48.        return true;
  49.     }
  50. }
  51. function moveToMouseLoc()
  52. {
  53. if(pltsTipLayer.innerHTML=='')return true;
  54. var MouseX=event.x;
  55. var MouseY=event.y;
  56. //window.status=event.y;
  57. var popHeight=pltsTipLayer.clientHeight;
  58. var popWidth=pltsTipLayer.clientWidth;
  59. if(MouseY+pltsoffsetY+popHeight>document.body.clientHeight)
  60. {
  61.    popTopAdjust=-popHeight-pltsoffsetY*1.5;
  62.    pltsPoptop.style.display="none";
  63.    pltsPopbot.style.display="";
  64. }
  65. else
  66. {
  67.     popTopAdjust=0;
  68.    pltsPoptop.style.display="";
  69.    pltsPopbot.style.display="none";
  70. }
  71. if(MouseX+pltsoffsetX+popWidth>document.body.clientWidth)
  72. {
  73.    popLeftAdjust=-popWidth-pltsoffsetX*2;
  74.    topleft.style.display="none";
  75.    botleft.style.display="none";
  76.    topright.style.display="";
  77.    botright.style.display="";
  78. }
  79. else
  80. {
  81.    popLeftAdjust=0;
  82.    topleft.style.display="";
  83.    botleft.style.display="";
  84.    topright.style.display="none";
  85.    botright.style.display="none";
  86. }
  87. pltsTipLayer.style.left=MouseX+pltsoffsetX+document.body.scrollLeft+popLeftAdjust;
  88. pltsTipLayer.style.top=MouseY+pltsoffsetY+document.body.scrollTop+popTopAdjust;
  89. return true;
  90. }
  91. pltsinits();

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

 

  1. <style>
  2. .tableBorder7{width:800;solidbackground-color#000000;}
  3. TD{font-family: 宋体;font-size12px;line-height : 15px ;}
  4. th{background-color#f7f7f7;color#000000;font-size12px;font-weight:bold;}
  5. th.th1{background-color#333333;}
  6. td.TableBody7{background-color#B1EA45;}
  7. </style>

搞定·····

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值