/* * include id-specified html into corresponding div */ window.addEventListener( "DOMContentLoaded", function () { function includeIdFiles() { for (let id of ["header", "footer"]) { let e = document.getElementById(id); if (!e) continue; let dir = (e.getAttribute("dir") || ".."), fn = dir + "/" + e.id + ".html"; fetch(fn).then((resp) => { resp.text().then((text) => { let newmenu = e.insertAdjacentHTML("afterend", text); e.remove(); newmenu.id = id; }); }); } } function init() { includeIdFiles(); } init(); });