0

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

Ajar Pix
  • 1
  • 3

1 Answers1

0

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.

roberrrt-s
  • 7,914
  • 2
  • 46
  • 57