开发者

UIWebView localStorage not working

I’m trying to write an app that uses localStorage in a UIWebView. I’ve tested my code in regular Safari on the desktop and it works perfectly. I’m not accessing localStorage with the web view itself, but the JS inside is accessing it.

Now, when I actually put my JS inside an UIWebView, localStorage stops working.

开发者_JAVA技巧

E.g. putting the following into JS

alert(localStorage)

doesn’t do anything. alerting window nicely alerts me the correct thing.

I tried it both on a iPad and in the simulator and it doesn’t seem to able to work anywhere. I don’t see any properties or anything I could tweak for the UIWebView that would make it either enabled or disabled.

Couldn’t find any tutorials either on the web that deal with my exact situation.


It seems the problem lies in the domain security policy. I was able to finally figure out what the error is, but not sure if my solution is even fixable with any simple way as I’m actually putting the whole HTML together from different NSStrings.

http://forrst.com/posts/Security_err_dom_exception_18_and_how_to_avoid-1Ge has one solution if you’re dealing with local files.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜