Skip to content

Instantly share code, notes, and snippets.

@duongthanhthai
Created February 22, 2024 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duongthanhthai/62fa64d07757677c5bd6c45397c4c7f6 to your computer and use it in GitHub Desktop.
Save duongthanhthai/62fa64d07757677c5bd6c45397c4c7f6 to your computer and use it in GitHub Desktop.
Auto redirect JavaScript
var timeLeft = 10; // Thời gian đợi là 10 giây
function countdown() {
document.getElementById('countdown').innerHTML = 'Nội dung bạn tìm kiếm không có, website sẽ quay về trang chủ Diễn đàn phật pháp trong ' + timeLeft + 's.';
timeLeft--; // Giảm thời gian đợi xuống mỗi giây
if (timeLeft < 0) {
clearTimeout(timerId);
window.location.href = 'https://diendanphatphap.com/diendan/'; // Chuyển hướng khi hết thời gian
}
}
var timerId = setInterval(countdown, 1000); // Cập nhật mỗi giây
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment