我希望实现以下目标:
如果是星期六或星期日,则显示我们已关闭页面。
如果不是星期六或星期日:
.如果在工作时间以外(不是上午 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>
我哪里错了?
开满天机
相关分类