Neil A.
Neil A.

Reputation: 841

How to link to file in root directory

I have a website with index.html in the root folder, and a folder named apples. Inside apples I have another index.html. Currently I am attempting to use AngularJS to load the same navbar into both pages. However, when I tried linking to the Javascript file like so: <script src="/controller.js">, the JS file loads for the index.html in the root folder, but it refuses to load the file for the index.html in the apples folder. Does anyone know why? In the apples folder, it keeps linking to apples//controller.js.

Upvotes: 0

Views: 4590

Answers (2)

Jon Ewing
Jon Ewing

Reputation: 392

Are you running this on a server or just on your desktop? The path /controller.js should work if you're running from a web server but likely won't work if you're calling it locally.

Upvotes: 2

Smit
Smit

Reputation: 2148

<script src="../js/controller.js"></script>
          __ ______ ________
          |    |       |
          |    |       |___ 3. Get the file named "logo.png"
          |    |
          |    |___ 2. Go inside "images/" subdirectory
          | 
          | 
          |____ 1. Go one level up

Reference

Upvotes: 0

Related Questions