科尔多瓦InAppBrowser清除搜索历史

问题描述 投票:0回答:1

我创建一个应用程序,你可以打开谷歌上找到答案的解决方案:

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

尽管我送的属性clearsessioncache = YES,clearcache = YES,我没有登录在谷歌就一直显示当我输入搜索框以前的搜索结果。

有人可以解释为什么在历史上一直显示在“建议”的网站?如果有什么办法来防止这种情况。

cordova cordova-plugins inappbrowser
1个回答
0
投票

找到自己的答案。希望它可以帮助别人同样的问题:

谷歌的搜索历史记录存储在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;
                });
        }
    });
});
© www.soinside.com 2019 - 2024. All rights reserved.