How to refer to JavaScript file in another folder


#1

Hello,

Here is my HTML code on Cloud9. This html file is in a folder called “HTML”

  <script src = "client/js/Hello_world.js"></script>
  <input type="button" onclick = "HelloWorld()" value ="Say Hello"/>

I am trying to refer to the Hello_world.js file which `is in a folder called “js”. During run time, the code is not able to refer to the javascript file. I tried the following combinations:

src = "Hello_world.js"
src = "/Hello_world.js"
src = “js/Hello_world.js”

but nothing seems to work.


#2

You can put JS folder into HTML folder as tempoary fix. Then you do:
src = "js/Hello_world.js"


#3

Here is an image of my project structure, all JavaScript is inside the js folder. And the way I call them like this.
<script type="text/javascript" src="js/profile.js"></script>