From c45fe27bacf3463440b80a84f07498d05bc17c3b Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sat, 26 Feb 2022 21:16:10 -0800 Subject: [PATCH] Use location.replace for 404 redirect This prevents adding an extra page in history, so users can press back once to go to the original page as expected. --- script.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index 0bb9f92..a536a2c 100644 --- a/script.js +++ b/script.js @@ -137,7 +137,8 @@ async function showPage(path) { else { // MUST redirect to a page where the web server serves an actual 404 error (i.e. not just // index.html again) otherwise this triggers an infinite loop - window.location.href = `${window.location.protocol}//${window.location.host}/errors/NotFound`; + document.title = '404: Not Found'; + window.location.replace(`${window.location.protocol}//${window.location.host}/errors/NotFound`); } } -- 2.47.3