Spent lot of time searching on the net to find a way to detect firefox private mode, could not find any hacks. I want to detect private mode because firefox tracking protection which is enabled by default is blocking a rest call to my api from my js application, so I want to detect private mode and display a proper message to the user.
Asked
Active
Viewed 1,842 times
1
-
2Why don’t you detect a failed API call and inform the user then? – Iso Jun 23 '16 at 15:34
1 Answers
-1
This seems to work in Firefox. I got it from this question. Look at this answer by Jez
try {
// try to use localStorage
localStorage.test = 2;
} catch (e) {
// there was an error so...
alert('You are in Privacy Mode\nPlease deactivate Privacy Mode and then reload the page.');
}
Apart from this, I think there is no way now, with modern browsers, to detect whether the user is using Privacy Mode and rightly so. That's why browsers have tried to shut off any way of detecting this using javascript or css.

Community
- 1
- 1

Mohit Bhardwaj
- 9,650
- 3
- 37
- 64
-
1Local Storage can be used in Firefox's private mode. Tested with Firefox Quantum v59.0.2. – Benny Code Apr 26 '18 at 13:06
-