龍華招生入口連結設定
by wllai2001
HTML
<!-- 禁止緩存的 meta 標籤 -->
<meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate, max-age=0">
<!-- Cache-Control 控制緩存的行為,no-store 表示完全禁止緩存,no-cache 表示必須總是驗證資源是否過期,must-revalidate 要求瀏覽器總是重新驗證快取。 max-age=0 表示立即過期。 -->
<meta http-equiv="Pragma" content="no-cache">
<!-- Pragma 是舊版 HTTP/1.0 的標籤,no-cache 表示不使用緩存。 -->
<meta http-equiv="Expires" content="0">
<!-- Expires 指定資源的到期時間,設為 0 表示已經過期。 -->
<div style="width: 960px; margin: 0 auto;" id="urlList">
<div style="margin-bottom: 10px;">
<a href="https://www.lhu.edu.tw/f/f1_1.html" target="_blank"><img src="https://www.lhu.edu.tw/images/turnimg/111banner5.png" alt="研究所招生資訊" style="" /></a>
</div>
<div style="margin-bottom: 10px;">
<a href="https://www.lhu.edu.tw/f/f2_1.html" target="_blank"><img src="https://www.lhu.edu.tw/images/turnimg/111banner1.png" alt="高中生申請入學招生" style="" /></a>
</div>
<div style="margin-bottom: 10px;">
<a href="https://www.lhu.edu.tw/f/f2_6.html" target="_blank"><img src="https://www.lhu.edu.tw/images/turnimg/111banner7.png" alt="四技轉學考招生資訊" style="" /></a>
</div>
<div style="margin-bottom: 10px;">
<a href="https://www.lhu.edu.tw/f/f3_4.html" target="_blank"><img src="https://www.lhu.edu.tw/images/turnimg/111banner4.png" alt="四技進修部招生資訊" style="" /></a>
</div>
<div style="margin-bottom: 10px;">
<a href="https://www.lhu.edu.tw/f/f2_5.html" target="_blank"><img src="https://www.lhu.edu.tw/images/turnimg/111banner3.png" alt="四技日間部招生資訊" style="" /></a>
</div>
<div style="margin-bottom: 10px;">
<a href="https://www.lhu.edu.tw/f/f6_2.html" target="_blank"><img src="https://www.lhu.edu.tw/images/turnimg/111banner8.png" alt="二技日間部招生資訊" style="" /></a>
</div>
<div style="margin-bottom: 10px;">
<a href="https://www.lhu.edu.tw/f/f2_12.html" target="_blank"><img src="https://www.lhu.edu.tw/images/turnimg/111banner9.png" alt="四技身心障礙學生資訊" style="" /></a>
</div>
<div...
CSS
img{
width: 960px; height: 120px; border: 0;
}
.hide{
display:none;
}
JavaScript
/*各區塊顯示日期*/
var setShowDatetim = [
{"class":"","Name":"研究所","sDate":"2024/01/05 00:00:00",eDate:"2024/01/06 00:00:00"},
{"class":"","Name":"高四技","sDate":"2024/01/01 00:00:00",eDate:"2024/01/04 00:00:00"},
{"class":"","Name":"轉四技","sDate":"2024/01/01 00:00:00",eDate:"2024/01/04 00:00:00"},
];
// 檢查當前日期時間是否在特定區段
var cDate = new Date();
//所有要控制顯示的DIV
var divs = document.querySelectorAll('#urlList > div');
// 遍歷日期區段陣列
for (var i = 0; i < setShowDatetim.length; i++) {
var sDate = new Date(setShowDatetim[i].sDate);
var eDate = new Date(setShowDatetim[i].eDate);
// 檢查是否在目前時段內
if (cDate >= sDate && cDate <= eDate) {
divs[i].classList.remove('hide');
console.log(setShowDatetim[i].Name + " 在目前時段內");
} else {
divs[i].classList.add('hide');
console.log(setShowDatetim[i].Name + " 不在目前時段內");
}
}