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
What is the proper format for src
to provide users with a link to engine.js
?
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.
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.
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.
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.
Use a double-dot to go back:
src="../engine/engine.js"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With