首页 > Web开发 > 详细

js在固定的时间在网页中央弹出广告图片或者对话框

时间:2021-04-02 17:28:12      阅读:29      评论:0      收藏:0      [点我收藏+]
<div id="light" class="white_content">
    <a href="javascript:void(0)" onclick="start1()" style="z-index:99;left: -5px;">×</a>
    <a href="">
        <img  src="./img/shang.jpg" width="100%" height="100%" alt="" >
    </a>
</div>
a{
    text-decoration: none;
    color: #000000;
    font-size: 30px;
}
#light{
    display: none;
}
.white_content{
    
    position: fixed;
    top: 0px;
    left: 0px;
    right: 0px;
    bottom: 0px;
    margin: auto;
    width: 300px;
    height: 300px;
    background-color: white;
    z-index: 1002;
    overflow: auto;
    border-radius: 25px;
}
#light a{
    position: relative;
    top: 0;
    float: right;
}
#light img{
    width: 100%;
    height: 100%;
    margin-top: -35px;
}
        
function one(){
 document.getElementById(‘light‘).style.display=‘block‘;
}
setTimeout(onclick=‘one()‘,3000);//先设定打开新网页3秒后弹出
        
function start1(){    
    document.getElementById(‘light‘).style.display=‘none‘;
    var d = setInterval(frame,5000);//在设置将首次弹出的图片关掉之后5秒后弹出图片
    var aa = document.getElementById(‘light‘);
    function frame(){
        if (aa.style.display=‘block‘) {
            clearInterval(d);
        } else{
            one();
            
        }
    }
}

通过js实现在网页的中间每隔5秒的时间弹出广告或者对话框

js在固定的时间在网页中央弹出广告图片或者对话框

原文:https://www.cnblogs.com/my-practice/p/14610315.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!