在页面加载时显示弹出窗口,然后定期显示和隐藏它

1 javascript jquery

我需要在页面首次加载时显示免责声明 div,然后定期显示和隐藏它。每三分钟展示一次是一个很好的时间间隔。

我目前有这个代码

<script>
function popup(){

setTimeout(function(){
document.getElementById("disclaimer").style.display = "block";
},0);
}
function hidePopup(){
document.getElementById("disclaimer").style.display = "none";
}
</script>
Run Code Online (Sandbox Code Playgroud)

然后我需要弹出窗口在大约 3 分钟时间过去后再次显示。

Mam*_*eed 5

尝试这个

//start showing popup
popup();

function popup() {

  document.getElementById("disclaimer").style.display = "block";

  console.log("wait 3 seconds then hide");

  setTimeout(hidePopup, 3000);

}

function hidePopup() {

  document.getElementById("disclaimer").style.display = "none";

  console.log("wait 3 minutes then show popup again");

  setTimeout(popup, 3 * 60 * 1000);

}
Run Code Online (Sandbox Code Playgroud)
<div id='disclaimer'>Disclaimer Div</div>
Run Code Online (Sandbox Code Playgroud)