-1

I've already did this for IE9 and lower users with conditional tags. But I have no idea how to address the problem on opera mini users. Also if possible I would like to block all versions of android default browser.

Thank you

I've found this way but Im not sure how to adress the browsers..

 <script>
  if (navigator.appName == "Opera Mini" && "Android Browser") {
  document.write("Your browser is not supported.");
  }
  </script>
Klaus
  • 1
  • 2
  • 8
  • 2
    Just curious why do you want to block users from your site?... this seems counter intuitive... would it not make more sense to suggest that they use a different browser?... and/or clearly indicate why they can't use Opera? (PS why can't they use Opera?) – scunliffe Jun 13 '13 at 19:42
  • 1
    He's creating FakeBlock, the anti-social network that prevents piracy. Duh. ;) – Jessica Jun 13 '13 at 19:44
  • http://www.useragentstring.com/pages/Opera%20Mini/ – Dave Chen Jun 13 '13 at 19:46
  • I think he just wants to block this simulator http://demo.opera-mini.net/public/ – Dave Chen Jun 13 '13 at 19:48
  • I want to block opera mini & android def browsers because they dont render my css properties properly when rest of browser do it. in other words there are better alternatives – Klaus Jun 13 '13 at 20:10
  • Don't block them... just send them [here](http://browsehappy.com) – Orangepill Jun 13 '13 at 20:11
  • Ok I will send them there, but I need someone to tell me how to do it because I have no js knowledge – Klaus Jun 13 '13 at 20:13
  • 1
    I hate to be the one to say it... but if the default android browser and opera don't handle your CSS... is there a chance that your CSS is invalid? Do you have a URL we could look at? PS providing a downgraded experience (if necessary) is likely better than denying a user altogether. – scunliffe Jun 13 '13 at 20:20
  • scunliffe I am sure my css code is ok. The problem are the browsers and the fact that Im using css3. So I need to change one of them, and since the market share of opera mini & android browser is close to non existtent and there are already MUCH better alternative, Im choosing to block them. – Klaus Jun 13 '13 at 20:23

3 Answers3

1

Try this script, your website could not be opened only for operamini

<?php
function DetectBrowser() {
$mobileBrowser= false;
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$newPage= "http://yourdomain.com/redirectpage.php"; 
$toRedirect=false;
    if (seemypage('/blackberry/i',$user_agent)) {
    $toRedirect=true; }
    if (seemypage('/opera mini/i',$user_agent)) { $toRedirect=true; }
    if ($toRedirect) {
    header('Location: '.$newPage); }
    }
?>
Martijn Pieters
  • 889,049
  • 245
  • 3,507
  • 2,997
EnnoDRart
  • 11
  • 2
0

I seriously don't know why you would want to do this, as you will lose a good percentage of your visitors.

But, You can download and use this PHP extension: https://code.google.com/p/php-mobile-detect/
It is called PHP Mobile Detect, and it can detect browsers, operating systems, copmuter types, etc... it may be useful for you! I can also post some code if needed.
I hope this helps!

pattyd
  • 5,249
  • 10
  • 35
  • 53
  • Hey thanks, I'll look into it right away. About losing visitors, I know but I have no other alternative.You can't have it all afterall and css3 & html5 and IE4 and other weak browsers ( or you can but I just don't see it worth it ) – Klaus Jun 13 '13 at 20:47
0

You can deny access to opera mini users with the .htaccess file

Add the following lines to your .htaccess file:

BrowserMatchNoCase opera bad_browser
Order Deny,Allow
Deny from env=bad_browser

Your problem is solved and you might use your error page to tell users to use another browser

Paul Roub
  • 35,100
  • 27
  • 72
  • 83
Ezenwa Hopekell
  • 25
  • 1
  • 10