const parser = new DOMParser(); fetch("/_bottomnav.html") .then(response => response.text()) .then(text => { const bottomNavHTML = parser.parseFromString(text, "text/html"); const bottomNav = bottomNavHTML.getElementById("bottomnav"); const pathSpan = bottomNav.querySelector("span"); pathSpan.innerText = pathSpan.innerText.replace("%PATH%", document.location.pathname); document.body.appendChild(bottomNav); });