set page title from mainMenu custom element

This commit is contained in:
Jonas Leder 2021-04-13 10:53:03 +02:00
parent cbd2eac1a9
commit 9b54ebf318
2 changed files with 9 additions and 1 deletions

View file

@ -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);

View file

@ -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 >