JS实现定时弹出广告

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS实现定时弹出广告</title>
    <script type="text/javascript">
        var time;
        /**
         * setInterval()方法会不断调用函数,直到clearInterval()被调用或者窗口被关闭。由setInterval()返回值的ID 值
         * 可用作clearInterval()方法的参数
         * 如果你只想执行一次可以使用setTimeout()方法
         * **/
        window.onload=function () {
           // var time =window.setInterval("imgblock()",2000);
            window.setTimeout("imgblock()",2000);
        }
        function imgblock() {
            var img_idDIV=document.getElementById("img_idDIV");
            img_idDIV.style.display="block";
           // window.clearInterval(time);
            //window.setInterval("imgNone()",2000);
        }
        function imgNone() {
            var img_idDIV=document.getElementById("img_idDIV");
            img_idDIV.style.display="none";
        }
    </script>
    <style>
        img{
            width: auto;
            height: auto;
            max-width:100%;
            max-height:100% ;
        }
    </style>
</head>
<body>
    <!-- border :border-width, border-style,和border-color.-->
    <!-- Position(定位):absolute 绝对定位 绝对定位的元素的位置相对于最近的已定位父元素,如果元素没有已定位的父元素,那么它的位置相对于<html>:-->
    <div id="img_idDIV" style="width: auto;position:absolute;right:0px;bottom:0px;overflow: hidden;display: none;">
       <a href="https://www.baidu.com/"><img src="./3/danei.jpg"></a>

    </div>

</body>
</html>

猜你喜欢

转载自www.cnblogs.com/topsyuan/p/11255518.html