Support for mouse Follow js+css link prompt box

Source: Internet
Author: User

Feel that pure CSS tips limited a little bit, and as if compatibility is not good, this is I found a js+css link prompt box effect, but also follow the mouse and move, and compatibility is good, the code share with you: front-end sharing

. Code
  1. <! DOCTYPE HTML public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">
  2. "http://www.w3.org/1999/xhtml">
  3. <title> follow the mouse text prompt box </title>
  4. <meta http-equiv="Content-type" content= "text/html; Charset=utf-8 " />
  5. <style type="Text/css">
  6. body{font:12px/1.8 Arial;}
  7. A,a:visited{color: #3366cc; text-decoration:none;}
  8. A:hover{color: #f60; text-decoration:underline;}
  9. . tip{width:200px;border:2px Solid #ddd;p adding:8px;background: #f1f1f1; color:#666;}
  10. Img{border:none;}
  11. </style>
  12. <script type="Text/javascript">
  13. var tip={$:function (ele) {
  14. if (typeof (ele) = ="Object")
  15. return ele;
  16. else if (typeof (ele) = ="string"| | typeof (Ele) = ="number")
  17. Return document.getElementById (Ele.tostring ());
  18. return null;
  19. },
  20. Mousepos:function (e) {
  21. var x, y;
  22. var e = e| | window.event;
  23. Return{x:e.clientx+document.body.scrollleft+document.documentelement.scrollleft,
  24. Y:e.clienty+document.body.scrolltop+document.documentelement.scrolltop};
  25. },
  26. Start:function (obj) {
  27. var = this;
  28. var t = self.$ ("Mjs:tip");
  29. Obj.onmousemove=function (e) {
  30. var mouse = Self.mousepos (e);
  31. T.style.left = mouse.x + + ' px ';
  32. T.style.top = mouse.y + + ' px ';
  33. t.innerhtml = Obj.getattribute ("Tips");
  34. T.style.display = ";
  35. };
  36. Obj.onmouseout=function () {
  37. T.style.display = ' None ';
  38. };
  39. }
  40. }
  41. </script>
  42. <body>
  43. <ol>
  44. <li><a href="#" target="_blank" onmouseover= "Tip.start(This)" tips=" December 14, 2013, the Chang ' E 3rd satellite landed on the moon, all the excitement finally arrived ... "> Some thoughts on the flying of Chang ' E in China </a></li>
  45. <li><a href="#" target="_blank" onmouseover= "Tip.start(This)" tips=" China's future must be the most powerful country in the world, do you believe it? "> China is the most powerful country in the world </a></li>
  46. </ol>
  47. <div id="Mjs:tip" class="Tip" style="Position:absolute;left:0;top:0;display:none;" ></div>
  48. </body>

This is to add a tips label for each a tag, which is displayed with JS control, so before you add this link hint to your page, copy the JavaScript code from the code to your page, and then add the Tips tab for the link that needs to be prompted. Front-end framework sharing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.