0

I have dragged a folder named mydocs and selected the "create folder references." option in coy menu. Here is my folder hierarchy.

|- mydocs
    |- newfolder
        |- anothernewfolder
            |- js
                |- main.js
        |- view
            |- html
                |- index.html

I have to call the main.js file from index.html file. For now I am using the absolute path "user/...../mydocs/newfolder/anothernewfolder/js/main.js" for including the file. It works like charm on simulator but when I run this on device I doesn't gets called.

How to call the .js files from the .html file residing in different directories?

After searching over the internet I found this answer in this post and by looking at it ../../anothernewfolder/js/main.js worked for me as .. means up one directory and . means current directory. So I have to go up two time for finding the directory of the .js files.

But I am unable to find how the .js file can refer to another .js file of different directory?

Community
  • 1
  • 1
Mayur Shrivas
  • 199
  • 1
  • 13

2 Answers2

1

try to use the following code in your index.html

../anothernewfolder/js/main.js
AmirtharajCVijay
  • 1,078
  • 11
  • 12
0

You need to call main.js like this in index.html in view folder:

<script type="text/javascript" src="../anothernewfolder/js/main.js"></script>
Amin
  • 414
  • 1
  • 11
  • 23