开发者

Using local resources in an iPhone webview

开发者 https://www.devze.com 2023-02-07 08:23 出处:网络
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 JQu

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消