I'm looking to achieve the following:
If it's Saturday or Sunday, show the we're closed page.
If it's not Saturday or Sunday:
.If it is outside of working hours (not between 9am and 12pm), show the we're closed page.
.If it is within working hours, show the we're open page.
Here is the code:
<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 = "https://golborne.abtrace-cloud.com"; // we are open
}
}
}
</script>
</head>
<body onload="ampmRedirect()">
</body>
</html>
Where am I going wrong?
Aucun commentaire:
Enregistrer un commentaire