From 1ac3e42c64bd66fd937b04847468d170d0e6ca59 Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Sat, 14 Nov 2020 16:51:36 +0100 Subject: [PATCH] Moved error correction --- js/navbar.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/navbar.js b/js/navbar.js index 3cb4c5d..f07c311 100644 --- a/js/navbar.js +++ b/js/navbar.js @@ -2,17 +2,17 @@ function setactivePage() { var path = window.location.pathname; var tmp = path.split("/").pop(); var page = tmp.replace(".html", ""); + if (page == "") page = "home"; + console.log("page:" + page); var site = document.getElementsByClassName("canactive"); len = site !== null ? site.length : 0; i = 0; for (i; i < len; i++) { - if(page == "") page = "home"; - console.log("page:" + page); var siteClass = document.getElementsByClassName(page); len2 = siteClass !== null ? siteClass.length : 0; j = 0; - for(j; j < len2; j++) { - siteClass[j].classList.add("active"); + for (j; j < len2; j++) { + siteClass[j].classList.add("active"); } } }