从本机iPhone应用程序访问UIWebView本地存储数据 [英] Accessing UIWebView local storage data from native iPhone app

查看:133
本文介绍了从本机iPhone应用程序访问UIWebView本地存储数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个包含UIWebView组件的原生iPhone应用程序。该组件访问互联网webapp,webapp使用HTML5本地存储离线存储数据。

I'm writing a native iPhone app that contains a UIWebView component. This component accesses an internet webapp and the webapp stores data offline using HTML5 local storage.

是否可以从本机应用程序访问本地存储数据?

Is it possible to access this local storage data from the native app ?

推荐答案

我当时希望做类似的事情。简而言之,DOM和所有元素都不能直接访问。但是,您可以通过破解来获取数据。您需要做的是将自己的javascript注入下载的网页。然后评估结果。

I was looking to do something similar to this. In short, the DOM and all elements are not directly accessible. However, you can hack things up to get at the data. What you have to do is inject your own javascript into the downloaded webpage. Then evaluate the results.

此页面显示了执行此操作的机制:

This page shows the mechanism for doing it:

http://iphoneincubator.com/blog/windows-views/怎么注入-javascript-functions-into-aiwebview

然后你只需要知道数据库的名称并创建一些javascript到返回JSON字符串中的值。使用cocoa JSON解析器从该字符串创建可在本机应用程序中使用的对象。

Then you just need to know the name of the database and create some javascript to return the values in a JSON string. Use a cocoa JSON parser to create objects from that string that you can use in your native app.

这篇关于从本机iPhone应用程序访问UIWebView本地存储数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆