jquery鼠标移上去图片提示

 

 

 
  
  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. <style type="text/css"> 
  6. html { overflow:-moz-scrollbars-vertical; } /*Always show Firefox scrollbar*/ 
  7. body{ font:12px/22px "宋体"; word-break:break-all; text-align:left; background:#C0C0C0; color:#4E4E4E;} 
  8. ul,li{ list-style:none;} 
  9. a{ color:#333; text-decoration:none;} 
  10. a:hover{ color:#ff722d; text-decoration:none;} 
  11. img{ border:0;} 
  12. a img,a:hover img{ border:0;} 
  13. .latestWeb{ width:980px; margin:10px auto 0;} 
  14. .latestWeb ul{ overflow:hidden; _height:1%;} 
  15. .latestWeb li{ float:left; border:1px solid #EBEAEA; width:150px; padding:10px; margin:14px 14px 0 0; } 
  16. .trans_msg{ filter:alpha(opacity=100,enabled=1) revealTrans(duration=.2,transition=1) blendtrans(duration=.2);} 
  17. div.bodycontent{font-family:Arial, Helvetica, sans-serif;padding:0 10px 10px 13px;color:#555;line-height:22px;text-align:justify;text-justify:inter-ideograph;} 
  18. div.bodycontent ul{margin-left:0px} 
  19. </style> 
  20. </head> 
  21.  
  22. <body style="text-align:center"> 
  23.  
  24. <div class="latestWeb"> 
  25. <ul> 
  26. <li class=""> 
  27. <div style="width:128px; height:126px"><a href="http://www.webdm.cn/" target="_blank"><img src='http://www.webdm.cn/p_w_picpaths/20100909/20095121750198009074_small.jpg' onMouseOver="toolTip('<img src=http://www.webdm.cn/p_w_picpaths/20100909/20095121750198009074.jpg>')" onMouseOut="toolTip()"></a></div> 
  28. </li> 
  29. <li class=""> 
  30. <div style="width:128px; height:126px"><a href="http://www.webdm.cn/" target="_blank"><img src='http://www.webdm.cn/p_w_picpaths/20100909/2009512172933475478_small.jpg' onMouseOver="toolTip('<img src=http://www.webdm.cn/p_w_picpaths/20100909/2009512172933475478.jpg>')" onMouseOut="toolTip()"></a></div> 
  31. </li> 
  32. <li class=""> 
  33. <div style="width:128px; height:126px"><a href="http://www.webdm.cn/" target="_blank"><img src='http://www.webdm.cn/p_w_picpaths/20100909/200957188213477090_small.jpg' onMouseOver="toolTip('<img src=http://www.webdm.cn/p_w_picpaths/20100909/200957188213477090.jpg>')" onMouseOut="toolTip()"></a></div> 
  34. </li> 
  35. <li class=""> 
  36. <div style="width:128px; height:126px"><a href="http://www.webdm.cn/" target="_blank"><img src='http://www.webdm.cn/p_w_picpaths/20100909/2009511102511591969_small.jpg' onMouseOver="toolTip('<img src=http://www.webdm.cn/p_w_picpaths/20100909/2009511102511591969.jpg>')" onMouseOut="toolTip()"></a></div> 
  37. </li> 
  38. <li class=""> 
  39. <div style="width:128px; height:126px"><a href="http://www.webdm.cn/" target="_blank"><img src='http://www.webdm.cn/p_w_picpaths/20100909/2009511956153474660_small.jpg' onMouseOver="toolTip('<img src=http://www.webdm.cn/p_w_picpaths/20100909/2009511956153474660.jpg>')" onMouseOut="toolTip()"></a></div> 
  40. </li> 
  41. <li class=""> 
  42. <div style="width:128px; height:126px"><a href="http://www.webdm.cn/" target="_blank"><img src='http://www.webdm.cn/p_w_picpaths/20100909/20095121752382849770_small.jpg' onMouseOver="toolTip('<img src=http://www.webdm.cn/p_w_picpaths/20100909/20095121752382849770.jpg>')" onMouseOut="toolTip()"></a></div> 
  43. </li> 
  44. <li class=""> 
  45. <div style="width:128px; height:126px"><a href="http://www.webdm.cn/" target="_blank"><img src='http://www.webdm.cn/p_w_picpaths/20100909/200955181403758690_small.jpg' onMouseOver="toolTip('<img src=http://www.webdm.cn/p_w_picpaths/20100909/200955181403758690.jpg>')" onMouseOut="toolTip()"></a></div> 
  46. </li> 
  47. <li class=""> 
  48. <div style="width:128px; height:126px"><a href="http://www.webdm.cn/" target="_blank"><img src='http://www.webdm.cn/p_w_picpaths/20100909/2009551813457815940_small.jpg' onMouseOver="toolTip('<img src=http://www.webdm.cn/p_w_picpaths/20100909/2009551813457815940.jpg>')" onMouseOut="toolTip()"></a></div> 
  49. </li> 
  50. <li class=""> 
  51. <div style="width:128px; height:126px"><a href="http://www.webdm.cn/" target="_blank"><img src='http://www.webdm.cn/p_w_picpaths/20100909/200955181308903992_small.jpg' onMouseOver="toolTip('<img src=http://www.webdm.cn/p_w_picpaths/20100909/200955181308903992.jpg>')" onMouseOut="toolTip()"></a></div> 
  52. </li> 
  53. <li class=""> 
  54. <div style="width:128px; height:126px"><a href="http://www.webdm.cn/" target="_blank"><img src='http://www.webdm.cn/p_w_picpaths/20100909/200955181403758690_small.jpg' onMouseOver="toolTip('<img src=http://www.webdm.cn/p_w_picpaths/20100909/200955181403758690.jpg>')" onMouseOut="toolTip()"></a></div> 
  55. </li> 
  56. </ul> 
  57. </div> 
  58. <script language="javascript"> 
  59.     function getViewportHeight() { 
  60.         if (window.innerHeight != window.undefined) return window.innerHeight; 
  61.         if (document.compatMode == 'CSS1Compat') return document.documentElement.clientHeight; 
  62.         if (document.body) return document.body.clientHeight; 
  63.  
  64.         return window.undefined; 
  65.     } 
  66.     function getViewportWidth() { 
  67.         if (window.innerWidth != window.undefined) return window.innerWidth; 
  68.         if (document.compatMode == 'CSS1Compat') return document.documentElement.clientWidth; 
  69.         if (document.body) return document.body.clientWidth; 
  70.  
  71.         return window.undefined; 
  72.     } 
  73.  
  74.     /** 
  75.     * Gets the real scroll top 
  76.     */ 
  77.     function getScrollTop() { 
  78.         if (self.pageYOffset) // all except Explorer 
  79.         { 
  80.             return self.pageYOffset; 
  81.         } 
  82.         else if (document.documentElement && document.documentElement.scrollTop) 
  83.         // Explorer 6 Strict 
  84.         { 
  85.             return document.documentElement.scrollTop; 
  86.         } 
  87.         else if (document.body) // all other Explorers 
  88.         { 
  89.             return document.body.scrollTop; 
  90.         } 
  91.     } 
  92.     function getScrollLeft() { 
  93.         if (self.pageXOffset) // all except Explorer 
  94.         { 
  95.             return self.pageXOffset; 
  96.         } 
  97.         else if (document.documentElement && document.documentElement.scrollLeft) 
  98.         // Explorer 6 Strict 
  99.         { 
  100.             return document.documentElement.scrollLeft; 
  101.         } 
  102.         else if (document.body) // all other Explorers 
  103.         { 
  104.             return document.body.scrollLeft; 
  105.         } 
  106.     } 
  107.     /* 
  108.     渐变的弹出图片 
  109.     使用方法: 
  110.     将ToolTip.js包含在网页body的结束标签后 
  111.     调用方法: 
  112.     <a href="pages.jpg" target='_blank' onMouseOver="toolTip('<img src=http://zhouzh:90/templet/T_yestem_channel/pages_small.jpg>')" onMouseOut="toolTip()"><img src='pages_small.jpg' border=0 width=30 height=20 align="absmiddle" title="点击看大图"></a> 
  113.  
  114. 必须CSS样式 
  115.     .trans_msg 
  116.     { 
  117.     filter:alpha(opacity=100,enabled=1) revealTrans(duration=.2,transition=1) blendtrans(duration=.2); 
  118.     } 
  119.     */ 
  120.     //--初始化变量-- 
  121.     var rT = true; //允许图像过渡 
  122.     var bT = true; //允许图像淡入淡出 
  123.     var tw = 150; //提示框宽度 
  124.     var endaction = false; //结束动画 
  125.     var ns4 = document.layers; 
  126.     var ns6 = document.getElementById && !document.all; 
  127.     var ie4 = document.all; 
  128.     offsetX = 10
  129.     offsetY = 20
  130.     var toolTipSTYLE = ""
  131.     function initToolTips() { 
  132.         tempDiv = document.createElement("div"); 
  133.         tempDiv.id = "toolTipLayer"
  134.         tempDiv.style.position = "absolute"
  135.         tempDiv.style.display = "none"
  136.         document.body.appendChild(tempDiv); 
  137.         if (ns4 || ns6 || ie4) { 
  138.             if (ns4) toolTipSTYLE = document.toolTipLayer; 
  139.             else if (ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style; 
  140.             else if (ie4) toolTipSTYLE = document.all.toolTipLayer.style; 
  141.             if (ns4) document.captureEvents(Event.MOUSEMOVE); 
  142.             else { 
  143.                 toolTipSTYLE.visibility = "visible"
  144.                 toolTipSTYLE.display = "none"
  145.             } 
  146.             document.onmousemove = moveToMouseLoc
  147.         } 
  148.     } 
  149.     function toolTip(msg, fg, bg) { 
  150.         try { 
  151.             if (toolTip.arguments.length < 1) // hide 
  152.             { 
  153.                 if (ns4) { 
  154.                     toolTipSTYLE.visibility = "hidden"
  155.                 } 
  156.                 else { 
  157.                     //--图象过渡,淡出处理-- 
  158.                     if (!endaction) { toolTipSTYLE.display = "none"; } 
  159.                     if (rT) document.all("msg1").filters[1].Apply(); 
  160.                     if (bT) document.all("msg1").filters[2].Apply(); 
  161.                     document.all("msg1").filters[0].opacity = 0
  162.                     if (rT) document.all("msg1").filters[1].Play(); 
  163.                     if (bT) document.all("msg1").filters[2].Play(); 
  164.                     if (rT) { 
  165.                         if (document.all("msg1").filters[1].status == 1 || document.all("msg1").filters[1].status == 0) { 
  166.                             toolTipSTYLE.display = "none"
  167.                         } 
  168.                     } 
  169.                     if (bT) { 
  170.                         if (document.all("msg1").filters[2].status == 1 || document.all("msg1").filters[2].status == 0) { 
  171.                             toolTipSTYLE.display = "none"
  172.                         } 
  173.                     } 
  174.                     if (!rT && !bT) toolTipSTYLE.display = "none"
  175.                     //---------------------- 
  176.                 } 
  177.             } 
  178.             else // show 
  179.             { 
  180.                 if (!fg) fg = "#777777"
  181.                 if (!bg) bg = "#eeeeee"
  182.                 var content = 
  183.         '<table id="msg1" name="msg1" border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '" class="trans_msg"><td>' + 
  184.         '<table border="1" cellspacing="2" cellpadding="3" bgcolor="' + bg + 
  185.         '"><td><font face="Arial" color="' + fg + 
  186.         '" size="-2">' + msg + 
  187.         '</font></td></table></td></table>'; 
  188.  
  189.                 if (ns4) { 
  190.                     toolTipSTYLE.document.write(content); 
  191.                     toolTipSTYLE.document.close(); 
  192.                     toolTipSTYLE.visibility = "visible"
  193.                 } 
  194.                 if (ns6) { 
  195.                     document.getElementById("toolTipLayer").innerHTML = content
  196.                     toolTipSTYLE.display = 'block' 
  197.                 } 
  198.                 if (ie4) { 
  199.                     document.all("toolTipLayer").innerHTML = content
  200.                     toolTipSTYLE.display = 'block' 
  201.                     //--图象过渡,淡入处理-- 
  202.                     var cssopaction = document.all("msg1").filters[0].opacity 
  203.                     document.all("msg1").filters[0].opacity = 0
  204.                     if (rT) document.all("msg1").filters[1].Apply(); 
  205.                     if (bT) document.all("msg1").filters[2].Apply(); 
  206.                     document.all("msg1").filters[0].opacity = cssopaction
  207.                     if (rT) document.all("msg1").filters[1].Play(); 
  208.                     if (bT) document.all("msg1").filters[2].Play(); 
  209.                     //---------------------- 
  210.                 } 
  211.             } 
  212.         } catch (e) { } 
  213.     } 
  214.     function moveToMouseLoc(e) { 
  215.         var scrollTop = getScrollTop(); 
  216.         var scrollLeft = getScrollLeft(); 
  217.         if (ns4 || ns6) { 
  218.             x = e.pageX + scrollLeft; 
  219.             y = e.pageY - scrollTop; 
  220.         } 
  221.         else { 
  222.             x = event.clientX + scrollLeft; 
  223.             y = event.clientY; 
  224.         } 
  225.  
  226.         if (x - scrollLeft > getViewportWidth() / 2) { 
  227.             xx = x - document.getElementById("toolTipLayer").offsetWidth - 2 * offsetX; 
  228.         } 
  229.  
  230.         if ((y + document.getElementById("toolTipLayer").offsetHeight + offsetY) > getViewportHeight()) { 
  231.             y = getViewportHeight() - document.getElementById("toolTipLayer").offsetHeight - offsetY; 
  232.         } 
  233.         toolTipSTYLE.left = (x + offsetX) + 'px'; 
  234.         toolTipSTYLE.top = (y + offsetY + scrollTop) + 'px'; 
  235.         return true; 
  236.     } 
  237.     initToolTips(); 
  238.  
  239. </script> 
  240. </body> 
  241. </html>