adModule.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <div id="adModule" style="width:150px;height:432px;z-index: 1000">
  2. <!-- <img src="../images/position.png" alt=""> -->
  3. </div>
  4. <script>
  5. var Rimifon = {
  6. "Ads": new Object,
  7. "NewFloatAd": function (imgUrl, strLink) {
  8. var ad = document.getElementById("adModule");
  9. ad.DirV = true;
  10. ad.DirH = true;
  11. ad.AutoMove = true;
  12. ad.Image = new Image;
  13. ad.Seed = Math.random();
  14. ad.Timer = setInterval("Rimifon.Float(" + ad.Seed + ")", 50);
  15. this.Ads[ad.Seed] = ad;
  16. ad.Image.Parent = ad;
  17. ad.style.position = "fixed";
  18. ad.style.left = 0;
  19. ad.style.top = 0;
  20. ad.Image.src = imgUrl;
  21. ad.onmouseover = function () { this.AutoMove = false; }
  22. ad.onmouseout = function () { this.AutoMove = true; }
  23. var close = document.createElement("a");
  24. close.setAttribute("class", "closedd");
  25. ad.setAttribute("class", "closed_box");
  26. var countMessage = document.createElement('p');
  27. countMessage.setAttribute("class", 'jsMessage');
  28. if (strLink) {
  29. ad.href = strLink;
  30. ad.Image.border = 0;
  31. ad.target = "_blank";
  32. }
  33. ad.appendChild(ad.Image);
  34. ad.appendChild(close);
  35. ad.appendChild(countMessage);
  36. close.append('x');
  37. document.body.appendChild(ad);
  38. return ad;
  39. },
  40. "Float": function (floatId) {
  41. var ad = this.Ads[floatId];
  42. if (ad.AutoMove) {
  43. var curLeft = parseInt(ad.style.left);
  44. var curTop = parseInt(ad.style.top);
  45. if (ad.offsetWidth + curLeft > document.documentElement.clientWidth + document.body.scrollLeft - 1) {
  46. curLeft = document.body.scrollLeft + document.documentElement.clientWidth - ad.offsetWidth;
  47. ad.DirH = false;
  48. }
  49. if (ad.offsetHeight + curTop > document.documentElement.clientHeight + document.body.scrollTop - 1) {
  50. curTop = document.body.scrollTop + document.documentElement.clientHeight - ad.offsetHeight;
  51. ad.DirV = false;
  52. }
  53. if (curLeft < document.body.scrollLeft) {
  54. curLeft = document.body.scrollLeft;
  55. ad.DirH = true;
  56. }
  57. if (curTop < document.body.scrollTop) {
  58. curTop = document.body.scrollTop;
  59. ad.DirV = true;
  60. }
  61. ad.style.left = curLeft + (ad.DirH ? 3 : - 3) + "px";
  62. ad.style.top = curTop + (ad.DirV ? 3 : - 3) + "px";
  63. }
  64. }
  65. }
  66. </script>
  67. <script>
  68. var ad = Rimifon.NewFloatAd("/images/szxy.jpg");
  69. ad.style.left = 500;
  70. ad.style.top = 456;
  71. $(".closed_box").on("click", function () {
  72. window.open("http://www.creditprt.org.cn/index/center/code/NjMxLzc5My8wLzA=");
  73. })
  74. $(".closedd").on("click", function () {
  75. $(this).closest("div").remove();
  76. })
  77. </script>