Using local resources in an iPhone webview
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 ma开发者_JAVA技巧y 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?
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).
精彩评论