延遲跳轉可搭配 jQuery 的 ready 事件與原生 setTimeout()。頁面載入完成後,等待指定毫秒數,再導向新網址。
function delayer() {
window.location = 'https://www.example.com/';
}
jQuery(document).ready(function() {
setTimeout(delayer, 5000);
});
常見用途包括短暫顯示公告、倒數導向新頁面、或讓使用者閱讀提示訊息後再跳轉。若需要讓使用者自行取消,建議搭配倒數計時與取消按鈕。