-1

Thanks to anyone who solves/helps solving this request. Sorry if this is an impossible/previously asked request. I searched for it, couldn't find it, so posted a question.

So, the issue is, that I want my page to be visible/usable only by Chrome users. And to other users, either display nothing when they try to access the page or Display a message stating: "Please use Google Chrome for Accessing this page"

It is preferable if the code is in JS, but jQuery or PHP will also work.

Thanks again.

Best JS code:

var isChromium = window.chrome,
    vendorName = window.navigator.vendor,
    isOpera = window.navigator.userAgent.indexOf("OPR") > -1,
    isIEedge = window.navigator.userAgent.indexOf("Edge") > -1;
if(isChromium !== null && isChromium !== undefined && vendorName === "Google Inc." && isOpera == false && isIEedge == false) {
   // is Google chrome 
} else { 
   alert("Hello! I am an alert box!!");// not Google chrome 
}
Saumya Banthia
  • 127
  • 1
  • 3
  • 9

1 Answers1

0

You could use navigator.userAgent to filter users:

if(navigator.userAgent.indexOf("Chrome") != -1){

}
Lucas Rodrigues
  • 1,234
  • 2
  • 11
  • 22