Recently, I had the question "How to create a pop-up window that will be displayed only at a specified time." The user of the Rules forum helped me with this question. The code he gave me is:
<html> <head> <meta name="charset" content="utf-8"> <title>Окно</title> <style type="text/css"> #mywindow{ position: absolute; top: 25%; left: 25%; width: 50%; height: 50%; background-color: #FFF9AE; visibility: hidden; } #closewin{ position: absolute; top: 3px; right: 3px; width: auto; height: auto; background-color: #FFF9AE; text-decoration: underline; } #mywindow2{ position: absolute; top: 25%; left: 25%; width: 50%; height: 50%; background-color: #FFF9AE; visibility: hidden; } #closewin2{ position: absolute; top: 3px; right: 3px; width: auto; height: auto; background-color: #FFF9AE; text-decoration: underline; } </style> <script> function showWindow(){ var myWindow = document.getElementById("mywindow"); var myWindow2 = document.getElementById("mywindow2"); var nowDate = new Date(); if(nowDate.getDay() == 0 || nowDate.getDay() == 6){ myWindow.style.visibility = "visible"; } if(nowDate.getDay() == 1 || nowDate.getDay() == 2 || nowDate.getDay() == 3 || nowDate.getDay() == 4 || nowDate.getDay() == 5 || ( nowDate.getHours() <= 8 || nowDate.getHours() >= 21 )){ myWindow2.style.visibility = "visible"; } } function closeWin(){ var myWindow = document.getElementById("mywindow"); myWindow.style.visibility = "hidden"; } window.onload = showWindow; </script> </head> <body> <div id="mywindow"><div id="closewin" onclick="closeWin()">Закрыть</div>Выходной</div> <div id="mywindow2"><div id="closewin" onclick="closeWin()">Закрыть</div>Ночь</div> </body> </html>
Now the question is different: how to make one window pop up at night, and another on the weekend.