Hello
I am using the index-corporate as my template.
I am trying to keep the header and the footer in a separate html file so I can then include it into the different pages so I only need to change the one header/footer file to update all pages.
I tried to use
- php includes: <?php include "header.html" ?>
- with JS
putting <nav class=navbar> in html file and having JS file of
const nav = document.querySelector('.navbar')
fetch('header.html')
.then(res=>res.text())
.then(data=>{
nav.innerHTML=data
const parser = new DOMParser()
const doc = parser.parseFromString(data, 'text/html')
eval(doc.querySelector('script').textContent)
})
However, some styles get lost even after copying the whole header section from style.css into the header.html file. and the slider below the menu does not get appear.
How should I proceed? To be able to keep headers and footers in a separate file to make it modular?
Thanks a lot!
Kind regards
Jonas
