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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM