How to remove HTML5 persistant databases in UIWebV

2019-07-02 03:15发布

I have a native application that uses a UIWebView and notice that with sites like Google, they are using an HTML5 local database for storing information. I am using native APIs for clearing items out of the cookie store, but clearing the persistent cookie store does nothing to remove these local databases. Is there a way to remove them through a native API?

UPDATE:

Is there a way to do this through a non-native API or javascript?

标签: ios uiwebview
2条回答
霸刀☆藐视天下
2楼-- · 2019-07-02 03:32

You can remove all localstorage variables by using a function like this.

function clearStorage() {
  for(var i in localStorage)
  {
    localStorage.removeItem(i);
  }
}

Of course if you need to only get rid of certain variables or simply set them to default values types then this will have to be modified. I am not familiar enough with UIWebView or your use case to know which variables you would want removed.

查看更多
聊天终结者
3楼-- · 2019-07-02 03:36

You can run this JavaScript directly in your url bar:

javascript:localStorage.clear();

Note that local storage is same domain scoped, so it will clear the storage of the current domain that you are.

Currently google uses it for google Analytics, adSense, etc.

查看更多
登录 后发表回答