加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

漂浮广告可关闭

发布时间:2020-12-15 17:58:48 所属栏目:百科 来源:网络整理
导读:%--Keymo,漂浮广告--% SCRIPT type = "text/javascript" ? ?// 这是关闭飘浮广告的宽度,请根据你的广告内容而定 ? ? ?var hbcms_ad_width = 100 ; ? ? ?// 这是关闭飘浮广告的代码,可以换成图片,点击即可关闭 ? ? ?var hbcms_close_str = 'div onClick="c
  1. <%--Keymo,漂浮广告--%>

  2. <SCRIPTtype="text/javascript">

  3. ? ?// 这是关闭飘浮广告的宽度,请根据你的广告内容而定 ?

  4. ? ?var hbcms_ad_width = 100; ?

  5. ? ?// 这是关闭飘浮广告的代码,可以换成图片,点击即可关闭 ?

  6. ? ?var hbcms_close_str = '<div onClick="closeBanner();" style="color:gray;font-size:9pt;cursor:hand;text-align:center;width:100%;background-color: #efefef;line-height:200%">关闭</div>'; ?

  7. ? ?// 设置左边的广告代码,请自己更换图片地址,或换成flash,或换成纯文字 ?

  8. ? ?// 如果不希望显示左边的广告,可设置为 ? = ''; ?

  9. ? ?var hbcms_left_ad = '<embed src='#'" /images/left.jpg" width="100" height="300" quality="high" wmode="window"></embed>' + hbcms_close_str; ?

  10. ? ?// 设置右边的广告代码,如果要和左边的广告一致,可设为 = hbcms_left_ad; ?

  11. ? ?// 如果不希望显示右边的广告,可设置为 = ''; ?

  12. ? ?var hbcms_right_ad = '<embed src='#'" /images/right.jpg" width="100" height="300" quality="high" wmode="window"></embed>' + hbcms_close_str; ?

  13. ? ?var delta = 0.8; ?

  14. ? ?var collection; ?

  15. ? ?var closeB = false; ?

  16. ? ?function floaters() { ?

  17. this.items = []; ?

  18. this.addItem = function (id,x,y,content) { ?

  19. ? ? ? ? ? ?document.write('<DIVid=' + id + 'style="Z-INDEX: 10; POSITION: absolute; ? width:' + hbcms_ad_width + 'px; height:300px;left:' + (typeof (x) == 'string' ? eval(x) : x) + ';top:' + (typeof (y) == 'string' ? eval(y) : y) + '">' + content + '</DIV>'); ?

  20. ? ? ? ? ? ?var newItem = {}; ?

  21. newItem.object = document.getElementById(id); ?

  22. newItem.x = x; ?

  23. newItem.y = y; ?

  24. ? ? ? ? ? ?this.items[this.items.length] = newItem; ?

  25. ? ? ? ?} ?

  26. this.play = function () { ?

  27. collection = this.items ?

  28. ? ? ? ? ? ?setInterval('play()',30); ?

  29. ? ? ? ?} ?

  30. ? ?} ?

  31. ? ?function play() { ?

  32. ? ? ? ?if (screen.width <= 800 || closeB) { ?

  33. ? ? ? ? ? ?for (var i = 0; i <collection.length; i++) { ?

  34. ? ? ? ? ? ? ? ?collection[i].object.style.display = 'none'; ?

  35. ? ? ? ? ? ?} ?

  36. ? ? ? ? ? ?return; ?

  37. ? ? ? ?} ?

  38. ? ? ? ?for (var i = 0; i <collection.length; i++) { ?

  39. ? ? ? ? ? ?var followObj = collection[i].object; ?

  40. ? ? ? ? ? ?var followObj_x = (typeof (collection[i].x) == 'string' ? eval(collection[i].x) : collection[i].x); ?

  41. ? ? ? ? ? ?var followObj_y = (typeof (collection[i].y) == 'string' ? eval(collection[i].y) : collection[i].y); ?

  42. ? ? ? ? ? ?if (followObj.offsetLeft != (document.body.scrollLeft + followObj_x)) { ?

  43. ? ? ? ? ? ? ? ?var dx = (document.body.scrollLeft + followObj_x - followObj.offsetLeft) * delta; ?

  44. dx = (dx > 0 ? 1 : -1) * Math.ceil(Math.abs(dx)); ?

  45. followObj.style.left = followObj.offsetLeft + dx; ?

  46. ? ? ? ? ? ?} ?

  47. ? ? ? ? ? ?if (followObj.offsetTop != (document.body.scrollTop + followObj_y)) { ?

  48. ? ? ? ? ? ? ? ?var dy = (document.body.scrollTop + followObj_y - followObj.offsetTop) * delta; ?

  49. dy = (dy > 0 ? 1 : -1) * Math.ceil(Math.abs(dy)); ?

  50. followObj.style.top = followObj.offsetTop + dy; ?

  51. ? ? ? ? ? ?} ?

  52. followObj.style.display = ''; ?

  53. ? ? ? ?} ?

  54. ? ?} ?

  55. ? ?function closeBanner() { ?

  56. closeB = true; ?

  57. ? ? ? ?return; ?

  58. ? ?} ?

  59. ? ?var theFloaters = new floaters(); ?

  60. ? ?theFloaters.addItem('followDiv1','document.body.clientWidth-106',hbcms_ad_width,hbcms_right_ad); ?

  61. ? ?//右面广告属性,分别是id,content ?

  62. ? ?theFloaters.addItem('followDiv2',6,hbcms_left_ad); ?

  63. ? ?//左面广告属性,content ?

  64. ? ?theFloaters.play(); ?

  65. </script>

  66. <%--漂浮广告结束--%>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读