Garmaine Staff asked 1 year ago

I'm trying to create a simple off-line site (shared through Dropbox) that will serve as a knowledge base for my team. I'd like a way to pull the side bar site navigation links from one file since we'll have team members constantly updating it and don't want to have them updating them across dozens of pages.

I'm seeing the HTML include solution could work but I can't get it to work, I’m testing with a simple hyperlink in my navigation file:

<a href="new_pg.html">How to Add a New Page</a>

Any ideas what I'm doing wrong?

<!DOCTYPE html>
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:*/
      }   "GET", file, true);
      /*exit the function:*/

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
<link href="css/styles.css" rel="stylesheet" type="text/css">
<script src=""></script>


<div class="sidenav">
<div class="nav-divider-line"></div>

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


<div class="nav-divider-line"></div>

<div class="main">
Main Content

/* Loop through all dropdown buttons to toggle between hiding and showing its dropdown content - This allows the user to have multiple dropdowns without any conflict */
var dropdown = document.getElementsByClassName("dropdown-btn");
var i;

for (i = 0; i < dropdown.length; i++) {
  dropdown[i].addEventListener("click", function() {
  var dropdownContent = this.nextElementSibling;
  if ( === "block") { = "none";
  } else { = "block";