jquery – Include another HTML file in an HTML file

Question:

Scenario: I'm putting together a layout, which will be used by third parties and I don't know what language will be used. I have two divs, one will be the left menu and one the content. They are separated by a Splitter , my questions are:

  1. This left menu, I want to develop a separate html and call it by include , what is the best way to do it?

  2. If I make a call via javascript will I have problems with javascript contained in this page that will be inserted?

  3. Is there any such pattern in HTML5 , CSS or some simple way to implement it in JavaScript ?


I know iframe is not a good solution. Through <object type="text/html" data="include.html"></object> , it works but I don't think it's a good solution either.

Answer:

If you are using a webserver (eg Apache or IIS), it probably supports Server-side includes . With that you could use, in the main HTML:

<!-- #include file="caminho-do-menu.html" -->
Scroll to Top