1

I'm a complete beginner in web design. I couldn't find an answer after some search. I purchased a template to create my personal website, and now I'm editing the navigation bar data. Yet, it seems that I have to copy and paste this in every single html file that has the navigation bar, which doesn't seem right. Is there a way to have all this data in a single file, and then edit it once so that it's automatically included in all pages? Thank you. aa

aaragon
  • 2,314
  • 4
  • 26
  • 60
  • possible duplicate of [best practice to create a template in html](http://stackoverflow.com/questions/16132341/best-practice-to-create-a-template-in-html) – Quentin Apr 28 '13 at 14:11

2 Answers2

0

Just include nav.html where you want it to be(inside your code):

 include('nav.html');

You main code must be in index.html.Put the code for nav in nav.html and then include nav.html in index.html where you want your nav to be.

Dchris
  • 2,867
  • 10
  • 42
  • 73
  • Thanks Dchris for your answer. Does this file has to only contain the code between – aaragon Apr 28 '13 at 14:41
  • Yes but pay attention to include your nav between the right
    – Dchris Apr 28 '13 at 15:15
  • I can't do it, and I don't know what's wrong. The code I have is as follows: `
    – aaragon Apr 28 '13 at 21:13
  • I don't know what I am doing wrong, but I just can't get it to work. As you saw in my previous comment, the – aaragon Apr 29 '13 at 12:07
-1

You save nav in single file, ex nav.htm , then included using iframe or java scirpt.

Iframe: <iframe src="nav.htm"></iframe>

Javasciprt, you can using jquery

 <html> 
  <head> 
    <script src="jquery.js"></script> 
    <script> 
    $(function{
      $("#nav").load("nav.htm"); 
    });
    </script> 
  </head> 

  <body> 
     <div id="nav"></div>
  </body> 
</html>
  • Hi @namthienmenh, I'm trying your approach but when I put the code on nav.htm the bar shows up in a different spot (and it lost its properties). Is the code you put above correct? – aaragon May 01 '13 at 19:38