diff --git a/js/main.js b/js/main.js index 2941798..3090a97 100644 --- a/js/main.js +++ b/js/main.js @@ -28,12 +28,15 @@ function openPage(page, new_url, renew_history) { return; } slideOpacity(function () { - document.getElementById(window.currPage + "-link").children[0].className = ""; + var link = document.getElementById(window.currPage + "-link"); + if (link) { + link.children[0].className = ""; + link.children[0].className = "active"; + } document.getElementById(window.currPage).className = "hiddenarea"; window.currPage = page; document.getElementById(page).style.opacity = "0"; document.getElementById(page).className = ""; - document.getElementById(page + "-link").children[0].className = "active"; var target = new_url || page; var targetPg = "/" + target; if (target == "about") { diff --git a/ts/main.ts b/ts/main.ts index 263bb49..b764b29 100644 --- a/ts/main.ts +++ b/ts/main.ts @@ -41,12 +41,16 @@ function openPage(page: string, new_url: string = null, renew_history=true) { if (page == window.currPage) { return; } slideOpacity(() => { - document.getElementById(window.currPage + "-link").children[0].className = "" + let link = document.getElementById(window.currPage + "-link"); + if (link) { + link.children[0].className = "" + link.children[0].className = "active" + } + document.getElementById(window.currPage).className = "hiddenarea"; window.currPage = page; document.getElementById(page).style.opacity = "0"; document.getElementById(page).className = ""; - document.getElementById(page + "-link").children[0].className = "active" let target = new_url || page; let targetPg = "/" + target; if (target == "about") { target = ""; targetPg = ""; };