Using local resources in an iPhone webview

无人久伴 提交于 2019-12-11 07:05:54

问题


Suppose an app has a webview that uses JQuery for example.

The server delivers the page with appropriate links to load JQuery, and the view works fine, but I would like it to not need to download JQuery (yes it may be cached, but it won't be the first time the app runs and I would rather not count on it)

So I can include the JQuery files with the app, but then how should I embed the links?

The server certainly doesn't know the bundle path.

I thought I could load the url into a string and then replace the JQuery paths with the local paths before displaying in the webview.

Is there an easier way?


回答1:


You can use relative paths for jQuery and set the baseURL to the bundle path. However that requires that all resources are in the bundle directory (except those which are referenced by an absolute path).



来源:https://stackoverflow.com/questions/4846151/using-local-resources-in-an-iphone-webview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!