javascript判断浏览器是否是隐私模式
判断浏览器是否是隐私模式,隐私模式下有写api不可用
1.
try { localStorage['test'] = 'test'; //localStorage和sessionStorage都存在,但是私有模式下不能赋值
} catch(e) { alert("本地储存写入错误,请关闭隐身模式浏览。"); }
2.
var fs = window.RequestFileSystem || window.webkitRequestFileSystem; if (!fs) { console.log("check failed"); } else { fs(window.TEMPORARY,100,function(){ alert('非隐身模式'); },function(){ alert('隐身模式'); }); }
参考:
http://stackoverflow.com/questions/2909367/can-you-determine-if-chrome-is-in-incognito-mode-via-a-script#answer-27805491
http://www.cnblogs.com/tujia/p/6026218.html
https://gist.github.com/cou929/7973956