Reuben Perryman
Reuben Perryman

Reputation: 17

link to external .js file does not work

I currnently have my files place on a virtual server (USB Webserver V8.2). Now when go on the server, open the page nothing happens. I know its something to do with the link path name, but I have tried changing the link in many different ways but nothing.

<script type="text/javascript" src="/root/help_page_code.js"></script>

Upvotes: 0

Views: 1195

Answers (3)

ThdK
ThdK

Reputation: 10546

  • Open you page in google chrome. Hit the F12 key to opene the developer menu.
  • In the first tab (Elements), look if your script file is in the head of your html
  • In the second tab (Resources) look for the script and hover over its name. Then you'll see the actual path that is used to find your script

Validate if that is the same path as the physical path on your server.

If both the script and the webpage are in the same folder, you can choose this:

<script type="text/javascript" src="help_page_code.js"></script>

Upvotes: 0

kiswa
kiswa

Reputation: 14987

That's a relative path, so the server is looking for a directory named root in the folder of the web page.

If you're trying to go up a directory from the page, just make it ../root/help_page_code.js. If you're going up further, and have access, just add a ../ for each level.

Upvotes: 1

antyrat
antyrat

Reputation: 27765

Try to add dot . before path:

<script type="text/javascript" src="./root/help_page_code.js"></script>

Upvotes: 0

Related Questions