繁体   English   中英

谷歌登录不在safari私人模式下工作

[英]Google signin not working in safari private mode

我使用此文档在我的webapp中包含Google登录但是当我尝试在私有模式下从Safari加载网站时,我总是在控制台中出现以下错误

QuotaExceededError: DOM Exception 22: An attempt was made to add something to storage that exceeded the quota.
setItem4187590794-idpiframe.js:19:293
g4187590794-idpiframe.js:19:293
Ea4187590794-idpiframe.js:30
(funzione anonima)4187590794-idpiframe.js:33
onreadystatechange4187590794-idpiframe.js:11:477

我知道私有模式下的safari不允许在localStorage写入,但是没有任何解决方法让google登录也可以在私有模式下工作吗?

谢谢

不要让Safari私有浏览模式中的localStorage / sessionStorage setItem抛出错误

看看这个: https//gist.github.com/philfreo/68ea3cd980d72383c951

// Safari, in Private Browsing Mode, looks like it supports localStorage but all calls to setItem
// throw QuotaExceededError. We're going to detect this and just silently drop any calls to setItem
// to avoid the entire page breaking, without having to do a check at each usage of Storage.
if (typeof localStorage === 'object') {
    try {
        localStorage.setItem('localStorage', 1);
        localStorage.removeItem('localStorage');
    } catch (e) {
        Storage.prototype._setItem = Storage.prototype.setItem;
        Storage.prototype.setItem = function() {};
        alert('Your web browser does not support storing settings locally. In Safari, the most common cause of this is using "Private Browsing Mode". Some settings may not save or some features may not work properly for you.');
    }
}

已知Safari私密浏览会导致此类问题。 解决此问题的最简单方法是更改​​localStorage函数。

尝试这个

function isLocalStorageNameSupported() 
{
    var testKey = 'theTestKey', storage = window.sessionStorage;
    try 
    {
        storage.setItem(testKey, '1');
        storage.removeItem(testKey);
        return localStorageName in win && win[localStorageName];
    } 
    catch (error) 
    {
        return false;
    }
}

您可以在此处找到详细的文档和其他解决方案: https//github.com/marcuswestin/store.js/issues/42

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM