If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

How to block all other browsers except chrome?!

Hello,

i want to know, how can i block all other browsers on my website except chrome users? I would like to allow just chrome browser users, all other users i would like to redirect to some example link. I think it can be done with javascript, so please provide me some code example, so i can use it on my website.

It's recommended in the documentation for the navigator browser object to ideally search for feature detection rather than browser detection depending what it is you want to do. Certain browsers do not return information for navigator.vendor, such as IE, making it a little more browser specific.

The USER_AGENT can also be checked and acted upon with .htaccess. This method doesn't rely upon someone having JavaScript turned on in their browser. A "belt and suspenders" approach is to use both. But as iBeZi stated, it can still be spoofed.

However, you may want to consider that blocking other browsers is a throw back to those users who claim you should get a real web browser and that the person trying to view may not be in a position to install chrome or have the technical ability to do so.

Restricting user access to a single type of browser is a virtual version of cutting your nose off to spite your face.

You should also know that if JavaScript is not present like some browsers out in the WWW do not have javascript or understand javascript (yes they do exist) or even turned off would mean that your blocking script would fail.

--> JavaScript Frameworks like JQuery, Angular, Node <--
... and please remember to wrap code with forum BBCode tags:- [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]If you can't think outside the box, you will be trapped forever with no escape...

The USER_AGENT can also be checked and acted upon with .htaccess. This method doesn't rely upon someone having JavaScript turned on in their browser. A "belt and suspenders" approach is to use both. But as iBeZi stated, it can still be spoofed.

The term kevin2 is "Belts and Braces" approach.

--> JavaScript Frameworks like JQuery, Angular, Node <--
... and please remember to wrap code with forum BBCode tags:- [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]If you can't think outside the box, you will be trapped forever with no escape...

It's recommended in the documentation for the navigator browser object to ideally search for feature detection rather than browser detection depending what it is you want to do. Certain browsers do not return information for navigator.vendor, such as IE, making it a little more browser specific.