0

When learned to make JSP pages, I was taught to use a common menu page separate from all other pages and then import the menu page to each page using <jsp:directive.include file="menu.jspx" />.

Is there a similar way to do this in HTML5? Or is there a better way to include a common menu/masthead on every page using HTML5?

Szuturon
  • 931
  • 4
  • 17
  • 28
  • possible duplicate of [Why does HTML5 not include a way of loading local HTML into the document?](http://stackoverflow.com/questions/6875404/why-does-html5-not-include-a-way-of-loading-local-html-into-the-document) – Jamie Dixon May 09 '12 at 15:23

2 Answers2

0

The standard way to do this is to use Server Side Includes. Most servers support this.

Further reading here

Jamie Dixon
  • 53,019
  • 19
  • 125
  • 162
0

No, html5 doesn't do this.

What you were doing in JSP was a server-side include. What you are asking for is a client-side include, those don't exist in html5.

I you had a good reason for loading something client-side, you could use javascript. Look into AJAX. A lot of .js libraries have good support, to make it easier. jQuery for example has a load() function which takes some of the pain away.

I don't recommend using something like that for a navigation menu though. Server-side includes would be better.

If you're simply working on a small project, maybe you're doing it locally, and you just want to make it so you don't have to copy-paste chunks of the page everywhere, php is an easy way to do it.

Use something like XAMPP to run php on your machine in an easy-to-follow way. Then use php's include function, as demonstrated here: PHP Include to do what you want.

daveyfaherty
  • 4,585
  • 2
  • 27
  • 42
  • Thank you very much. I'm working on a small company website and am looking for the best way to do it. – Szuturon May 09 '12 at 15:56