0

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.

ndruss
  • 1
  • 1
  • 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 Answers3

3

HTML5 imports should do the trick

<link rel="import" href="/path/to/imports/stuff.html">
0

I suppose you could send off an ajax request using jQuery's get method but it's not really ideal. Other than that, you could use an iframe.

Cjmarkham
  • 9,484
  • 5
  • 48
  • 81
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>