From 9b54ebf318dfb0f36bf207ba5e61a867791aff7b Mon Sep 17 00:00:00 2001 From: Jonas Leder <git@jonasled.de> Date: Tue, 13 Apr 2021 10:53:03 +0200 Subject: [PATCH] set page title from mainMenu custom element --- js/customElements/mainMenu.js | 9 +++++++++ public/internal/header.php | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/js/customElements/mainMenu.js b/js/customElements/mainMenu.js index 9be85c5..945d541 100644 --- a/js/customElements/mainMenu.js +++ b/js/customElements/mainMenu.js @@ -16,6 +16,11 @@ class MainMenu extends HTMLElement { a.innerText = element["name"]; menuContainer.appendChild(a); + + if(window.location['pathname'] === element["url"]){ + document.title = element["name"] + " - Jonas Leder"; + } + } else if(element["type"] === "dropdown"){ let dropdown = document.createElement("div"); dropdown.className = "dropdown"; @@ -37,6 +42,10 @@ class MainMenu extends HTMLElement { let br = document.createElement("br"); dropdownContent.appendChild(br); + + if(window.location['pathname'] === childElement["url"]){ + document.title = childElement["name"] + " - Jonas Leder"; + } }); dropdown.appendChild(dropdownContent); diff --git a/public/internal/header.php b/public/internal/header.php index b065e9e..e0582fd 100644 --- a/public/internal/header.php +++ b/public/internal/header.php @@ -10,7 +10,6 @@ function getHeader($pagetitle) <head > <meta charset = "UTF-8" > <meta name = "viewport" content = "width=device-width, initial-scale=1.0" > - <title > $pagetitle - Jonas Leder </title > <link href = "/css/style.css" rel = "stylesheet" > </head > -- GitLab