<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秒的时间弹出广告或者对话框