6

I am starting to develop an application using bootstrap, did some research on how to have static left navigation bar and a dynamic content area on the right side but could not get a clue. Can somebody advice how to change only the content area (separate html page) every time a link is clicked and have a static navigation bar and header. Something like frameset tag available in HTML.

Basically i would not want to have a navigation bar code added to all the html pages in the application.

Thanks

Mujahid
  • 127
  • 1
  • 2
  • 10

2 Answers2

3

I think frames died long ago.

To achieve 'navigation' you need to some kind of templating and routing. Take a look at Angular or React. Pretty much any server-side language has web frameworks with templates.

Relevant discussion of how to achieve similar behaviour to frames: What are the new frames?

Eriks Klotins
  • 4,042
  • 1
  • 12
  • 26
-3

Its 2018 and no one use frame tag anymore i prefer this solution for u hope this help

see also on W3schools How TO - Include HTML

content.html

<a href="howto_google_maps.asp">Google Maps</a><br>
<a href="howto_css_animate_buttons.asp">Animated Buttons</a><br>
<a href="howto_css_modals.asp">Modal Boxes</a><br>
<a href="howto_js_animate.asp">Animations</a><br>
<a href="howto_js_progressbar.asp">Progress Bars</a><br>
<a href="howto_css_dropdown.asp">Hover Dropdowns</a><br>
<a href="howto_js_dropdown.asp">Click Dropdowns</a><br>
<a href="howto_css_table_responsive.asp">Responsive Tables</a><br>

Include the HTML

<div w3-include-html="content.html"></div>

Add the JavaScript

<script>
function includeHTML() {
  var z, i, elmnt, file, xhttp;
  /*loop through a collection of all HTML elements:*/
  z = document.getElementsByTagName("*");
  for (i = 0; i < z.length; i++) {
    elmnt = z[i];
    /*search for elements with a certain atrribute:*/
    file = elmnt.getAttribute("w3-include-html");
    if (file) {
      /*make an HTTP request using the attribute value as the file name:*/
      xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
        if (this.readyState == 4) {
          if (this.status == 200) {elmnt.innerHTML = this.responseText;}
          if (this.status == 404) {elmnt.innerHTML = "Page not found.";}
          /*remove the attribute, and call this function once more:*/
          elmnt.removeAttribute("w3-include-html");
          includeHTML();
        }
      } 
      xhttp.open("GET", file, true);
      xhttp.send();
      /*exit the function:*/
      return;
    }
  }
}
</script>
Ismail Farooq
  • 6,309
  • 1
  • 27
  • 47