In short, I am using tags to import web page header/footer HTML. The following successfully loads the header only in Chrome. Is there a better practice in importing header/footer without using PHP, or a fix for this to work in Firefox?
<head>
<link rel="import" href="header.html">
</head
<body>
<script>
var head = document.getElementsByTagName('head')[0];
var doc = head.querySelector('link[rel="import"]').import;
//get the header html
var text = doc.querySelector('#header');
document.body.appendChild(text.cloneNode(true));
</script>
</body
Aucun commentaire:
Enregistrer un commentaire