【发布时间】:2016-06-29 23:42:48
【问题描述】:
我有一个带有“持久分区”的 webview 的 Chrome 应用程序,我需要一个按钮来清除保存在该 webview 分区中的所有数据。我已经根据官方谷歌示例尝试了以下解决方案,但我无法让它工作
var clearDataType = {
appcache:true,
cookies: true,
fileSystems: true,
indexedDB: true,
localStorage: true,
webSQL: true,
}
function clearCache() {
document.getElementById('webview-window').clearData(
{ since: 0 }, // Remove all browsing data.
clearDataType, function() {console.log('cache cleared');});
}
app中的webview是这样的:
<webview id="webview-window" src="http://www.google.ca" partition="persist:cache1">
每当我按下运行上述 clearCache() 函数的按钮时,我都会收到错误消息:“未捕获的 typeError:...clearData is not a function”。
我以前从未以这种方式使用过网络视图,因此非常感谢任何额外的解释。
【问题讨论】:
标签: javascript google-chrome webview google-chrome-app