working in Dreamweaver, not in Chrome
I have a website with a few working pages. I wanted to replace the nav bar on each page with a placeholder and load the code from a common file. The situation is that it works in the Live view of Dreamweaver, but doesn't work when I load the same code into Chrome. I am not sure if maybe the jquery thing doesn't work with Chrome in local files.
According to Stack Overflow I am supposed to do this:
(1) Place this in the <head> of my document:
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src=/script
(2) Place the nav bar code in nav.html (this is using the W3.CSS framework)
<div class="w3-bar w3-padding w3-card-2 w3-blue-gray" style="letter-spacing:2px;">
<a href="index.html" class="w3-bar-item w3-button w3-mobile">Home</a>
<div class="w3-dropdown-hover w3-mobile">
<button class="w3-button w3-mobile" style="letter-spacing: 2px;">The Journey</button>
<div class="w3-dropdown-content w3-bar-block w3-card-2 w3-blue-gray" style="letter-spacing:2px;">
<a href="finding.html" class="w3-bar-item w3-button">It's like finding your way home</a>
<a href="finding.html" class="w3-bar-item w3-button">It's like finding your way home</a>
<a href="#" class="w3-bar-item w3-button">Link 2</a>
<a href="#" class="w3-bar-item w3-button">Link 3</a>
</div>
</div>
<a href="#about" class="w3-bar-item w3-button w3-mobile">About</a>
<a href="#menu" class="w3-bar-item w3-button w3-mobile">Menu</a>
<a href="#contact" class="w3-bar-item w3-button w3-mobile">Contact</a>
</div>
(3) put a placeholder in each web pages, such as index.html:
<div id="nav-placeholder"></div>
Add this script somewhere in the body (can this go anywhere?):
<script>
$(function(){
$("#nav-placeholder").load("nav.html");
});
</script>
Is this even the right way to do it?
