对联广告

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" text="text/html";charset="UTF-8">
    <title></title>
</head>
<body>
<script type="text/javascript">    
    var AD_left,AD_right;
    function initAD(){
        AD_left = document.getElementById("AD_left");
        AD_right = document.getElementById("AD_right");
        AD_left.style.visibility = "visible";
        AD_left.style.position = "absolute";
        AD_left.style.zIndex = 1;
        AD_right.style.visibility = "visible";
        AD_right.style.position = "absolute";
        //zIndex表示层叠顺序,默认值为0,值越大表示离用户越近。
        //zIndex只对定位元素有效
        AD_right.style.zIndex = 1;
        //setTimeout() 方法用于在指定的毫秒数后调用函数或计算表达式
        //通过不断地执行moveAD(),使图片位于网页两侧
        setTimeout("moveAD(AD_left)",20);
        setTimeout("moveAD(AD_right)",20);

    }
    function moveAD(ADName){
        var x = 500;
        var y = 340;
        var diff = (document.body.scrollTop + y - ADName.style.posTop)*30;
        var y = document.body.scrollTop + y - diff;
        ADName.style.top = y + "px";//图片距顶部的距离
        if (ADName == AD_left) {
            ADName.style.left = x + "px";
        }
        if (ADName == AD_right) {
            ADName.style.right = x + "px";//图片距左右两侧的距离
        }
    }
    function closeAD(ADName){
        ADName.parentNode.style.visibility="hidden";
    }
    document.write("<div id='AD_left'>");
    document.write("<img src='img/1.jpg' width='134px' height='20px' οnclick='javascript:closeAD(this);void(0);'style='display:block' />");
    document.write("<img src='img/2.jpg' width='134px' height='200px'/>");
    document.write("</div>")
    document.write("<div id='AD_right' style='display:block;right:0px'>");
    document.write("<img src='img/1.jpg' width='134px' height='20px' οnclick='javascript:closeAD(this);void(0);'style='display:block' />");
    document.write("<img src='img/3.jpg' width='134px' height='200px'/>");
    document.write("</div>");
    initAD();
</script>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值