我希望實現以下目標:如果是星期六或星期日,則顯示我們已關閉頁面。如果不是星期六或星期日:.如果在工作時間以外(不是上午 9 點到中午 12 點之間),顯示我們已關閉頁面。.如果是在工作時間內,顯示我們開放的頁面。這是代碼:<html><head><TITLE>Golborne Patient Booking Portal </TITLE><script language="JavaScript" type="text/javascript">function ampmRedirect() { var currentTime = new Date(); var currentHour = currentTime.getHours(); var d = new Date(); var n = d.getDay(); if (n == 0) || (n == 6){ // if Saturday or Sunday window.location.href = "closed.html"; // we are closed } else { // if it is any other day if ((currentHour < 8) || (currentHour > 11)) { // if outside of working hours (8am to noon) window.location.href = "closed.html"; // we are closed } else { // anything else (not weekday or within the times) window.location.href = "open.html"; // we are open } }}</script></head><body onload="ampmRedirect()"></body></html>我哪里錯了?
為什么這個簡單的(嵌套的)if 語句不起作用?
慕碼人2483693
2023-04-14 16:37:35