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
Asked
Active
Viewed 186 times
2 Answers
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
-
-
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>

namthienmenh
- 76
- 5
-
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