问题
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
- engine
What is the proper format for src to provide users with a link to engine.js?
回答1:
Use a double-dot to go back:
src="../engine/engine.js"
回答2:
That would be:
<script type ="text/javascript" src ="../engine/engine.js"/>
来源:https://stackoverflow.com/questions/8889354/path-in-src-to-reach-a-file-in-a-different-directory