From 83bcda89518c6c3574cf575ce5c7cfdd750f4118 Mon Sep 17 00:00:00 2001 From: Deepak Khatri <lorforlinux@beagleboard.org> Date: Mon, 25 Nov 2024 01:47:12 +0530 Subject: [PATCH] Fix Uncaught TypeError: document.getElementById(...) is null --- _templates/404.html | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/_templates/404.html b/_templates/404.html index e2431403..ebac32c6 100644 --- a/_templates/404.html +++ b/_templates/404.html @@ -105,14 +105,16 @@ } } - if (!redirectFound) { - // In case the link test doesn't include redirectFolders - const headingElement = document.getElementById('pageHeading'); - if (headingElement) { - headingElement.textContent = "Page Not Found (404)"; + document.addEventListener("DOMContentLoaded", function () { + if (!redirectFound) { + // In case the link test doesn't include redirectFolders + const headingElement = document.getElementById('pageHeading'); + if (headingElement) { + headingElement.textContent = "Page Not Found (404)"; + } + document.getElementById('redirectInfo').style.display = "block"; } - document.getElementById('redirectInfo').style.display = "block"; - } + }); </script> {{ super() }} -- GitLab