0

I am creating a web site include navigation bar using only front end code...html ,css and script. but I want to add nav bar in each page by an already created html file.

I am using HTML5 that deprecated frameset tag. So which technique could I use without other backend code to add that html file to another one? Thanks.

<frameset rows="200,*" frameborder="no" border="0" id="container" scrolling="yes">
    <frame src="nav.html" name="leftframe" scrolling="no" noresize="noresize" id="nav" />
    <frame src="slider.html" name="rightframe" scrolling="no" noresize="noresize" id="slider" />
    <frame src="text.html" name="bottomframe" scrolling="no" noresize="noresize" id="text" />
    <frame src="copy.html" name="bottomframe" scrolling="no" noresize="noresize" id="text" />
</frameset>
George
  • 36,413
  • 9
  • 66
  • 103
Aung Thet
  • 3,051
  • 3
  • 13
  • 18
  • As far as I know there's no way to "include" html files. Best bet is to use php - is this an option? – user5623896726 Mar 27 '14 at 09:05
  • You can include it using jQuery Load() if you are using jQuery or you can use some php.For html , the only way to this is iframe – Charaf JRA Mar 27 '14 at 09:06
  • possible duplicate of [What are the new frames?](http://stackoverflow.com/questions/9466265/what-are-the-new-frames) – Quentin Mar 27 '14 at 09:13

2 Answers2

0

using jQuery:

<html> 
  <head> 
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
      <script> 
        $(function(){
         $("#navbar").load("navbar.html"); 
        });
      </script> 
  </head> 

  <body> 
   <div id="navbar"></div>
  </body> 
</html>
girardengo
  • 726
  • 12
  • 16
  • Don't do that unless you also follow the principles of [Progressive Enhancement](http://en.wikipedia.org/wiki/Progressive_enhancement) and [Unobtrusive JavaScript](http://en.wikipedia.org/wiki/Unobtrusive_JavaScript) – Quentin Mar 27 '14 at 09:13
0

You can switch <frame> for the <iframe> element and get the same results with some CSS.

João Simões
  • 1,351
  • 1
  • 10
  • 20