Cordova InAppBrowser 清除搜索历史记录

Cordova InAppBrowser clear search history

我正在创建一个应用程序,您可以在其中打开 google 以找到答案的解决方案:

 ref = cordova.InAppBrowser.open('https://google.nl/', '_blank', 'clearsessioncache=yes, clearcache=yes');

尽管我发送了属性 clearsessioncache=yes, clearcache=yes 并且我没有登录 Google 当我进入搜索框时它一直显示以前的搜索结果。

谁能解释为什么 'suggested' 网站上一直显示历史记录?如果有任何方法可以防止这种情况。

自己找到了答案。希望它能帮助遇到同样问题的其他人:

Google 搜索历史存储在 localStorage 中。因此在显示 InAppBrowser 之前清除 localStorage 可以解决问题:

this.ref = cordova.InAppBrowser.open('https://www.google.nl/', '_blank', 'clearsessioncache=yes,clearcache=yes,closebuttoncaption=Terug,closebuttoncolor=#4286f4,hideurlbar=yes,hidden=yes');
this.ref.addEventListener('loadstop', () => {
    var init = false
    this.ref.addEventListener('loadstop', () => {
        if (!init) {
            // clear localStorage to clear Google search history
            this.ref.executeScript({
                code: `
        (function() { 
            localStorage.clear();
            return true;
         })()` }, _ => {
                    // cache is cleared. Now we can show the browser.
                    this.ref.show();
                    init = true;
                });
        }
    });
});