This commit is contained in:
Unisko PENG, 2023-04-19 11:12:51 +08:00
parent f761480d76
commit c8807b0b3c
2 changed files with 27 additions and 0 deletions

9
src/404.md Normal file
View File

@ -0,0 +1,9 @@
### Document not found(404)
**文档未找到404**
抱歉,此 URL 无效。请使用导航栏或搜索继续。将在 <span class="sec-count" style="font-style: italic;font-weight:bold;font-size:large;">n</span> 秒后重定向到主页......
This URL is invalid, sorry. Please use the navigation bar or search to continue. It will be redirected to home in <span class="sec-count" style="font-style: italic;font-weight:bold;font-size:large;">n</span> seconds...

View File

@ -47,3 +47,21 @@ window.addEventListener('load', function() {
// Handle active elements on scroll
window.addEventListener("scroll", updateFunction);
if(document.querySelector("#document-not-found404")) {
let timeLeft = 10;
var timerId = setInterval(() => {
if(timeLeft == -1) {
clearTimeout(timerId);
let siteRoot = window.location.origin;
window.location.replace(siteRoot);
} else {
let secCounts = document.querySelectorAll(".sec-count")
secCounts.forEach(count => {
count.innerHTML = timeLeft;
});
timeLeft--;
}
}, 1000);
}