It is a best practice to NOT check browser versions to do feature support, instead, use feature detection. When detecting Chrome incognito mode, using feature detection might be a solution in Javascript. Use storage API is not a solution due to cross browser implementation difference regarding private window browsing.
Here is an example of using File API.
https://www.html5rocks.com/en/tutorials/file/filesystem/
function main() {
var fs = window.RequestFileSystem || window.webkitRequestFileSystem;
if (!fs) {
result.textContent = "check failed?";
return;
}
fs(window.TEMPORARY, 100, function(fs) {
result.textContent = "it does not seem like you are in incognito mode";
}, function(err) {
result.textContent = "it seems like you are in incognito mode";
});
}
No comments:
Post a Comment