漂浮廣告可關閉

  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="jx_html/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="jx_html/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,x,y,content  

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

  63.    //左面廣告屬性,分別是id,x,y,content  

  64.    theFloaters.play();  

  65. </script>

  66. <%--漂浮廣告結束--%>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章