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?
尝试在index.html中使用以下代码
../anothernewfolder/js/main.js
您需要在view文件夹的index.html中这样调用main.js:
<script type="text/javascript" src="../anothernewfolder/js/main.js"></script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.