Sometime before, we had talked about the incognito mode in Google chrome browser. Today, we are going to see how we can detect it using simple lightweight JavaScript.Before moving further, let we see what happens in Incognito mode or how incognito mode is different from normal browses?
Incognito mode or private browsing is the same normal browser but with deducted and controlled functions. Functions like saving history and cookies are disabled. through the websites can store cookies, they are deleted once the browser or incognito session closed.
Google, on its help page says that in Incognito mode-
Incognito mode or private browsing is the same normal browser but with deducted and controlled functions. Functions like saving history and cookies are disabled. through the websites can store cookies, they are deleted once the browser or incognito session closed.
Google, on its help page says that in Incognito mode-
- Chrome wont save our history.
- Downloaded files and bookmarks will b kept.
- Your activity isn't hidden from ISP or school or college employee.
But still, we can find that user is in Incognito mode or not.
Everything Seems Fine
Add this one line code(after minifying) in your HTML's <head> section and in place of JavaScript alert, us your own function.
How to Detect if the user is in Incognito mode?
For that, From a answer on stackoverflow, I came to know that window.RequestFileSystem function returns in error.So by using try catch, we can find if the user is in incognito mode.var fs = window.RequestFileSystem || window.webkitRequestFileSystem;
fs(window.TEMPORARY, 100, function(fs) {}, function(e) {
alert("You are in Incognito Mode.")
});
So this way you can detect in Google chrome if the user is in incognito mode.Live Demo
Everything Seems Fine
What others are saying
Since you can detect that user is in incognito mod or not, many says that this is the threat to their privacy and anonymity.Since Google chrome and other browsers may define temporary storage in feature that will clear immediately after the session closes. Then it will be more difficult for us to detect the incognito mode.Add this one line code(after minifying) in your HTML's <head> section and in place of JavaScript alert, us your own function.
not working
ReplyDelete