Newer
Older
web / jdinit.js
@HIROSE Yuuji HIROSE Yuuji on 22 Jun 2021 513 bytes Divide header and footer into separate files
/*
 * include id-specified html into corresponding div
 */
window.addEventListener(
"DOMContentLoaded",
function () {
    function includeIdFiles() {
	for (let id of ["header", "footer"]) {
	    let e  = document.getElementById(id),
		fn = 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();
});