Is there any way to force users to visit the webpage only in private window. (redirect to incognito mode webpage). I thing redirecting in html not possible. please help
-
Private as in incognito mode? – roberrrt-s Aug 30 '16 at 12:24
-
2There's no reliable way to do that. What are you trying to achieve? – Pointy Aug 30 '16 at 12:30
-
Chrome extensions like adblock plus will not work in private window. Adblockers wont block ads in incognito mode – Ajar Pix Aug 30 '16 at 12:38
-
This is not true, I have Adblock Plus enabled in Chrome when using Incognito Mode. – roberrrt-s Aug 30 '16 at 12:38
1 Answers
There is absolutely 100% no way for a website to know if a user has private / incognito mode enabled.
There are several 'checks' you can execute however, by testing if a user has localStorage / JavaScript enabled. But these tests will never fully point to a user in private / incognito mode.
EDIT: Seems your question is an obfuscated version of 'How can I avoid ad blocking?'
Use this in your HTML:
<div id="advertisment"></div>
Use this in your CSS:
#advertisement {
width: 468px;
height: 60px;
}
Use this in your JavaScript:
var ad = document.getElementById('advertisement');
if(!ad) {
// user has an ad blocker installed
return false;
}
This creates a bogus advertisement section on your website, which will get blocked by any adblocker for displaying the characteristics of one. In JavaScript, we check if the element still exists, and if it doesn't, we can do something about it.
An alternative way would be to load 'advert.js' with value var adblock = true;
and have your script.js
check for this variable.

- 7,914
- 2
- 46
- 57