browser conditional comments

I use this code to allow ie10 and all other browsers ,

ie10 + all other browsers

but i also want to forbid chrome , so what should be conditional comment

i would like to allow ie10 and all other browsers but [not chrome in other browsers list]

I’m an absolute novice, so i may be wrong in offering this, but here goes.

I used something like this before, although not for Chrome, it was actually to block IE, but i think it should work.

Forgive me if it doesn’t

[php]<?php
if ( isset($_SERVER[‘HTTP_USER_AGENT’]) )
{
$t_bIsChrome = strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Chrome’);
if ( $t_bIsChrome !== false)
{
echo “Sorry, this website isn’t compatible with Google Chrome.”;
exit;
}
}
?>[/php]

In theory this should detect Chrome and Present the error message.

You could also achieve something similar by using .htaccess … i’ve never used this method but you need to insert relevant user agent strings, off which there are many, but it would look something like this

#redirect those user agents to another page. RewriteEngine on RewriteCond %{HTTP_USER_AGENT} ^useragent-string1 [OR] RewriteCond %{HTTP_USER_AGENT} ^useragent-string2 [OR] RewriteCond %{HTTP_USER_AGENT} ^useragent-string3 RewriteRule ^(.*)$ http://mysite.com/errorpage.html

I am sure lots of people will correct me … I hope so, then i might learn something

Sponsor our Newsletter | Privacy Policy | Terms of Service