如何获得存储在应用程序绑定到HTML文件中的JavaScript文件(JS)路径是存在于文件目录

问题描述:

I have one .js file named final.js which I copied as bundle resource I have a requirement like the html document which reads this js file should download at runtime and store it in documents directory. But the js file is not able to read by the html when I loaded it in webview, because of the path of .js file. 

I tried with the solution like below, but not worked. 

<script src ="./final.js"> </script>如何获得存储在应用程序绑定到HTML文件中的JavaScript文件(JS)路径是存在于文件目录

最后,我试图复制的硬编码路径像下面的应用程序包,现在它工作。最后我知道路径不合适。

> <script src ="/Users/unknownUser/Library/Application Support/iPhone 
> Simulator/7.0/Applications/025EF3B6-F2E6-4162-8921-839D7D98FF58/HTMLGetdataTestApp.app/final.js"> 
> </script>` 

任何一个可以告诉我这是存储在文件目录中的HTML文件,如何读取存储在主束用正确的路径,而不是硬编码像上面.js文件。

简单的解决方案是将final.js文件复制到文档目录。

复制从包到文档目录(其中HTML页面所在)的js文件,并设置路径为:

<script src ="final.js"> </script> 
+0

谢谢回复,我已经完成了。但我的一个更多的要求是final.js文件不应该透露给外部应用程序。所以我只需要将它捆绑在一起。 –

+0

@KarthikMitta:AFAIK,如果您未启用iTunes文件共享选项,则可以看到文档目录中的文件。 –

+0

请探讨Ifunbox软件,它可以暴露每一件事情,甚至捆绑资源文件,但我的意图是至少我可以让人们不知道关于IFunbox的安全文件。对于IFunbox也,如果deveice被锁定了pin然后没有人可以提取任何东西。 –