From a8c6daa431b3e71cf1a62f49c50ed46a9477d3a4 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 26 Nov 2022 07:34:50 +0200 Subject: [PATCH] fix console error --- files/assets/js/core.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/files/assets/js/core.js b/files/assets/js/core.js index 5f8d31533..90dabc812 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -180,14 +180,18 @@ function smoothScrollTop() } // Click navbar to scroll back to top -document.getElementsByTagName('nav')[0].addEventListener('click', (e) => { - if (e.target.id === "navbar" || - e.target.classList.contains("container-fluid") || - e.target.id == "navbarResponsive" || - e.target.id == "logo-container" || - e.target.classList.contains("srd")) - smoothScrollTop(); -}, false); +const nav = document.getElementsByTagName('nav') + +if (nav) { + nav[0].addEventListener('click', (e) => { + if (e.target.id === "navbar" || + e.target.classList.contains("container-fluid") || + e.target.id == "navbarResponsive" || + e.target.id == "logo-container" || + e.target.classList.contains("srd")) + smoothScrollTop(); + }, false); +} // Dynamic shadow when the user scrolls document.addEventListener('scroll',function (event) {