鼠标移动提示的广告代码:如何实现广告随鼠标移动提示(转)

  1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2<html xmlns="http://www.w3.org/1999/xhtml">
  3<head>
  4<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5<title>通用title提示</title>
  6<style>
  7DIV {
  8        FONT-SIZE: 12pt
  9}

 10FORM {
 11        FONT-SIZE: 9pt
 12}

 13{
 14        FONT-SIZE: 9pt
 15}

 16TD {
 17        FONT-SIZE: 9pt
 18}

 19BODY {
 20        FONT-SIZE: 9pt
 21}

 22BODY {
 23        SCROLLBAR-HIGHLIGHT-COLOR: buttonface; SCROLLBAR-SHADOW-COLOR: buttonface; SCROLLBAR-3DLIGHT-COLOR: buttonhighlight; SCROLLBAR-TRACK-COLOR: #eeeeee; SCROLLBAR-DARKSHADOW-COLOR: buttonshadow
 24}

 25.menuskin {
 26        BORDER-RIGHT: #9ec5fc 1px solid; BORDER-TOP: #9ec5fc 1px solid;  VISIBILITY: hidden; BORDER-LEFT: #9ec5fc 1px solid; BORDER-BOTTOM: #9ec5fc 1px solid; POSITION: absolute
 27}

 28.menuitems {
 29        PADDING-RIGHT: 1px; PADDING-LEFT: 1px; FONT-SIZE: 9pt; PADDING-BOTTOM: 1px; MARGIN: 2px; LINE-HEIGHT: 14pt; PADDING-TOP: 1px
 30}

 31#mouseoverstyle {
 32        BORDER-RIGHT: #9ec5fc 1px solid; PADDING-RIGHT: 0px; BORDER-TOP: #9ec5fc 1px solid; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; BORDER-LEFT: #9ec5fc 1px solid; PADDING-TOP: 0px; BORDER-BOTTOM: #9ec5fc 1px solid; BACKGROUND-COLOR: #dae9fe
 33}

 34.menuskin A {
 35        PADDING-RIGHT: 10px; PADDING-LEFT: 30px
 36}

 37{
 38        FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 18px; FONT-FAMILY: "宋体"; TEXT-DECORATION: none
 39}

 40
 41pb {
 42        FONT-SIZE: 14px; FONT-FAMILY: "宋体"
 43}

 44A:hover {
 45        COLOR: #ff0000; TEXT-DECORATION: underline
 46}

 47A:visited {
 48        COLOR: #000000
 49}

 50.menu {
 51        COLOR: #00009c; TEXT-DECORATION: none
 52}

 53
 54.f7 {
 55        FONT-SIZE: 7px; COLOR: #207ab7
 56}

 57.red {
 58        COLOR: #ff3300
 59}

 60BODY {
 61        BACKGROUND-POSITION: center center;  BACKGROUND-REPEAT: repeat-y; BACKGROUND-COLOR: #dee7f7
 62}

 63TH {
 64        FONT-WEIGHT: bold; FONT-SIZE: 12px;  COLOR: white; HEIGHT: 25px; BACKGROUND-COLOR: #4fa0f2
 65}

 66.Menu_popup {
 67        DISPLAY: none
 68}

 69TD.TableTitle1 {
 70        COLOR: #000000; BACKGROUND-COLOR: #6595d6
 71}

 72TD.TableTitle2 {
 73        BACKGROUND-COLOR: #6595d6 
 74}

 75TD.TableBody1 {
 76        LINE-HEIGHT: normal; BACKGROUND-COLOR: #ffffff
 77}

 78TD.TableBody2 {
 79        LINE-HEIGHT: normal; BACKGROUND-COLOR: #6595d6
 80
 81}

 82TD.TableBody3 {
 83        BACKGROUND-COLOR: #6595d6
 84}

 85
</style>
 86<SCRIPT language=javascript>
 87var pltsPop=null;
 88var pltsoffsetX = 5;   // 弹出窗口位于鼠标左侧或者右侧的距离;3-12 合适                          
 89var pltsoffsetY = 15;  // 弹出窗口位于鼠标下方的距离;3-12 合适
 90var pltsPopbg="#FFFFEE"//背景色
 91var pltsPopfg="#111111"//前景色
 92var pltsTitle="";
 93document.write('<div id=pltsTipLayer style="display: none;position: absolute; z-index:10001"></div>');
 94function pltsinits()
 95{
 96    document.onmouseover   = plts;
 97    document.onmousemove = moveToMouseLoc;
 98}

 99function plts()
100{  var o=event.srcElement;
101    if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
102    if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
103    pltsPop=o.dypop;
104    if(pltsPop!=null&&pltsPop!=""&&typeof(pltsPop)!="undefined")
105    {
106        pltsTipLayer.style.left=-1000;
107        pltsTipLayer.style.display='';
108        var Msg=pltsPop.replace(/\n/g,"<br>");
109        Msg=Msg.replace(/\0x13/g,"<br>");
110        var re=/\{(.[^\{]*)\}/ig;
111        if(!re.test(Msg))pltsTitle="提示";
112        else{
113          re=/\{(.[^\{]*)\}(.*)/ig;
114            pltsTitle=Msg.replace(re,"$1")+"&nbsp;";
115          re=/\{(.[^\{]*)\}/ig;
116          Msg=Msg.replace(re,"");
117          Msg=Msg.replace("<br>","");}

118          var attr=(document.location.toString().toLowerCase().indexOf("list.asp")>0?"nowrap":"");
119               var content =
120              '<table style="FILTER:alpha(opacity=90) shadow(color=#bbbbbb,direction=135);" id=toolTipTalbe border=0><tr><td width="100%"><table class=tableborder1 cellspacing="1" cellpadding="0" style="100%">'+ '<tr id=pltsPoptop><th height=18 valign=bottom><b><p id=topleft align=left>↖'+pltsTitle+'</p><p id=topright align=right style="display:none">'+pltsTitle+'↗</font></b></th></tr>'+
121
122              '<tr><td "+attr+" class=tablebody1 style="padding-left:14px;padding-right:14px;padding-top: 6px;padding-bottom:6px;line-height:135%">'+Msg+'</td></tr>'+
123              '<tr id=pltsPopbot style="display:none"><th height=18 valign=bottom><b><p id=botleft align=left>↙'+pltsTitle+'</p><p id=botright align=right style="display:none">'+pltsTitle+'↘</font></b></th></tr>'+
124              '</table></td></tr></table>';
125               pltsTipLayer.innerHTML=content;
126               toolTipTalbe.style.width=Math.min(pltsTipLayer.clientWidth,document.body.clientWidth/2.2);
127               moveToMouseLoc();
128               return true;
129       }

130    else
131    {
132            pltsTipLayer.innerHTML='';
133              pltsTipLayer.style.display='none';
134               return true;
135    }

136}

137
138function moveToMouseLoc()
139{
140        if(pltsTipLayer.innerHTML=='')return true;
141        var MouseX=event.x;
142        var MouseY=event.y;
143        //window.status=event.y;
144        var popHeight=pltsTipLayer.clientHeight;
145        var popWidth=pltsTipLayer.clientWidth;
146        if(MouseY+pltsoffsetY+popHeight>document.body.clientHeight)
147        {
148                  popTopAdjust=-popHeight-pltsoffsetY*1.5;
149                  pltsPoptop.style.display="none";
150                  pltsPopbot.style.display=""
151}

152         else
153        {
154                   popTopAdjust=0;
155
156                  pltsPoptop.style.display="";
157                  pltsPopbot.style.display="none";
158        }

159        if(MouseX+pltsoffsetX+popWidth>document.body.clientWidth)
160        {
161                popLeftAdjust=-popWidth-pltsoffsetX*2;
162                topleft.style.display="none";
163                botleft.style.display="none";
164                topright.style.display="";
165                botright.style.display="";
166        }

167        else
168        {
169                popLeftAdjust=0;
170                topleft.style.display="";
171                botleft.style.display="";
172                topright.style.display="none";
173                botright.style.display="none";
174        }

175        pltsTipLayer.style.left=MouseX+pltsoffsetX+document.body.scrollLeft+popLeftAdjust;
176        pltsTipLayer.style.top=MouseY+pltsoffsetY+document.body.scrollTop+popTopAdjust;
177          return true;
178}

179pltsinits();

180</SCRIPT>
181</head>
182
183<BODY leftMargin=0 topMargin=0 rightMargin=0><br /><br /><br /><br />
184<table width="770" border="0" cellspacing="0" cellpadding="0">
185  <tr>
186    <td bgcolor="#FFFFFF"><title="欢迎光临谷歌堂www.ggtang.com" href="#">鼠标移上来看看</a></td>
187  </tr>
188</table>
189</body>
190</html>
191
原文地址:https://www.cnblogs.com/zwl12549/p/864081.html