I am working on a site with 20+ pages and updating the main links on all pages becomes quite tiresome. I have been able to do this using PHP on a Wordpress template I created a while back, but the current site I am working on uses only HTML, CSS and jQuery and I would like to keep it that way.
Asked
Active
Viewed 514 times
0
-
no. html has no "programability". you need something server-side for this kind of thing. if you don't/can't have php, then consider going old school, and using something like server-side includes. – Marc B Nov 24 '15 at 21:11
-
I tried using the iframe element and it almost worked, but it left out all the CSS. Is iframe the best method for this? – ndruss Nov 24 '15 at 21:12
-
Thanks @MarcB, I'll look into that. – ndruss Nov 24 '15 at 21:13
-
you can use whatever you want. there is no "best" option. they all have positives and negatives. – Marc B Nov 24 '15 at 21:13
-
` – Paul Roub Nov 24 '15 at 21:13
3 Answers
0
One way to write your header as a JavaScript file like this:
// header.js
document.write('\
<em>Add your HTML code here</em>\
');
And then load your js file into your html files:
<html>
<body>
<p>This html content is written before header</p>
<script src="header.js"></script>
<p>And this one after</p>
</body>
</html>

Jussi Gustafsson
- 1
- 1
- 2