console
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial‑scale=1.0">
<title>循环弹窗</title>
<style>
*{margin:0;padding:0;box-sizing:border-box;}
body{background:#111;color:#fff;min-height:100vh;}
.popup-mask{
position:fixed;
inset:0;
background:rgba(0,0,0,0.75);
display:flex;
align-items:center;
justify-content:center;
z-index:9999;
}
.popup-box{
background:#ffffff;
color:#000;
padding:30px 24px;
border-radius:12px;
width:80%;
max-width:320px;
text-align:center;
}
.popup-box button{
margin-top:20px;
padding:10px 22px;
border:none;
background:#2185ff;
color:white;
border-radius:8px;
font-size:16px;
}
.hide{
display:none !important;
}
</style>
</head>
<body>
<div class="popup-mask hide" id="mask">
<div class="popup-box">
<div>小雾病毒小雾病毒小雾病毒</div>
<button id="closeBtn">关闭</button>
</div>
</div>
<script>
const mask = document.querySelector('#mask');
const closeBtn = document.querySelector('#closeBtn');
const intervalMs = 1;
let timer;
function showPopup(){
mask.classList.remove('hide');
}
function hidePopup(){
mask.classList.add('hide');
}
closeBtn.onclick = function(){
hidePopup();
}
//网页一打开马上弹窗,之后循环
showPopup();
timer = setInterval(showPopup, intervalMs);
</script>
</body>
</html>