Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Path in src to reach a file in a different directory

Tags:

I have a folder called projects and in it I have a game folder and an engine folder. I have my engine.js file inside the engine folder and I was wondering if I could access it with my game.html file from the other folder like so

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

Now, obviously the above doesn't work, but what I need to do is go back out of the game folder to the project folder and then into the engine folder.

File tree: projects folder

  • projects
    • engine
      • engine.js
    • game
      • game.js

What is the proper format for src to provide users with a link to engine.js?

like image 369
Oni Enzeru Avatar asked Jan 17 '12 03:01

Oni Enzeru


People also ask

How do I reference a file in another folder?

To reference a file in a subdirectory, write the directory name in front of the path, plus a forward slash, e.g. subdirectory/my-image.

How do I go up one directory in HTML?

Starting with ../ moves one directory backward and starts there. Starting with ../../ moves two directories backward and starts there (and so on...) To move forward, just start with the first sub directory and keep moving forward.

What does path to directory mean?

A path is a slash-separated list of directory names followed by either a directory name or a file name. A directory is the same as a folder.

How do you go up a directory in CSS?

Starting with “/” returns to the root directory and starts there. Starting with “../” moves one directory backwards and starts there. Starting with “../../” moves two directories backwards and starts there (and so on…) To move forward, just start with the first subdirectory and keep moving forward.


1 Answers

Use a double-dot to go back:

src="../engine/engine.js"

like image 64
njbair Avatar answered Sep 28 '22 08:09

njbair