zoukankan      html  css  js  c++  java
  • js飘窗

    广告页上总会出现飘窗效果:

    adver_pos_id = getOtherParameter("id");
    
    adver_Sid = getOtherParameter("Sid");
    
    document.write("<div id='fudong01' style='position:absolute;z-index:50000;'><a onClick='setNone(fudong01)' style='position:absolute;right:0px;top:-18px;cursor:pointer;display:block;48px;height:16px;font-size: 12px;color:#fff;text-align:center;background:#333;border:1px solid #999;overflow:hidden;font-family:宋体;'>×关闭</a><img src='images/pf.png' border='0' /></div>");
    
    function setNone(str_fd) {
        str_fd.style.display = "none";
    }
    
    var x = 0,
    y = 0
    
    var xin = true,
    yin = true
    
    var step = 3
    
    var delay = 100; //设置滚动时间 
    var obj = document.getElementById("fudong01")
    
    function floatAD() {
    
        var L = 0;
    
        var T = 0;
    
        var cw = document.documentElement.clientWidth || document.body.clientWidth;
    
        var ch = document.documentElement.clientHeight || document.body.clientHeight; //处理浏览器对document.body的兼容问题
        var R = (cw - obj.offsetWidth) / 2
    
        var B = ch - obj.offsetHeight;
    
        y++;
    
        var atop = 0;
    
        obj.style.left = x + document.body.scrollLeft + "px";
    
        if (document.documentElement.scrollTop == 0) {
    
            atop = document.body.scrollTop;
    
        } else {
    
            atop = document.documentElement.scrollTop
    
        }
    
        obj.style.top = y + atop + "px"
    
        x = x + step * (xin ? 1 : -1)
    
        if (x < L) {
            xin = true;
            x = L
        }
    
        if (x > R) {
            xin = false;
            x = R
        }
    
        y = y + step * (yin ? 1 : -1)
    
        if (y < T) {
            yin = true;
            y = T
        }
    
        if (y > B) {
            yin = false;
            y = B
        }
    
    }
    
    var itl = setInterval("floatAD()", delay)
    
    obj.onmouseover = function() {
        clearInterval(itl)
    }
    
    obj.onmouseout = function() {
        itl = setInterval("floatAD()", delay)
    }
  • 相关阅读:
    大数减法
    MySQL配置的一些坑
    最大流_Edmonds-Karp算法
    最小生成树两连
    最短路三连
    对拍
    Broadcast
    Intent
    Custom Views
    Fragment
  • 原文地址:https://www.cnblogs.com/tizi/p/8846539.html
Copyright © 2011-2022 走看看