Hello! Made the site and it is crookedly displayed on ie8 and below, on all the others is normal. How can I make a check on the browser and transfer it to another alternative page of the site automatically ???

  • For a cross-browser site, it is better to use feature detection than browser detection (I don’t know how to say it correctly in Russian) - Peter Olson
  • @PeterOlson, yes, but this is clearly not the case with old IE. - Qwertiy
  • @Qwertiy Why? - Peter Olson
  • Because their support for all sorts of features will never change, as well as a set of bugs that may be incompatible with your code. - Qwertiy

4 answers 4

On the client, you can throw. jQuery has a nice plugin
Well...

 if($.browser.msie && $.browser.version < 9){ location.href = 'http://domain.com'; } 
  • does not work .... - Kleimosc
  • What exactly is not working? Does the condition not work? Do not transfer to another site? Gives errors? Tell me - they will help you. - Sergey Snegirev
  • does not send this condition to the site, how do I understand this php script? - Kleimosc
  • Of course not. Client js script. - sepgg

Use conditional comments:

 <!--[if IE 6]>Разметка тут видима только для IE6<![endif]--> <!--[if gt IE 8]><!-->А тут - для IE строго больше 8 и всех остальных<!--<![endif]--> <!--[if lte IE 8]>Для IE8-<![endif]--> 
  • Well, why did not please answer? - Qwertiy
  • Because @Vadizar rewrote this answer after a year and a half by adding sample code and put a minus, did my answer become bad? - Qwertiy
  • @NickVolynkin, added :( - Qwertiy

Try adding the following code to the template:

 <?php $user_agent = $_SERVER['HTTP_USER_AGENT']; if (stripos($user_agent, 'MSIE 6.0') !== false && stripos($user_agent, 'MSIE 8.0') === false && stripos($user_agent, 'MSIE 7.0') === false) { if (!isset($HTTP_COOKIE_VARS["ie"])) { setcookie("ie", "yes", time()+60*60*24*360); header ("Location: /нужная страница"); } } ?> 
  • Not working for some reason - Kleimosc

A working solution on pure JS for all IE, the version of which is less than 9

 <!--[if lt IE 9]> <script type="text/javascript"> window.location = "http://www.google.com/"; </script> <![endif] -->