-3

i've been practising with bootstrap 4, and as you may know bootstrap 4 doesn't support internet explorer 8 now. This may become a problem so i was wondering is i could show a different website only on internet explorer 8, or is there a way to change some things on different browsers.

Dr Lemon
  • 91
  • 1
  • 4
  • You could check the user-agent server-side to see what browser the clients using, and deliver what ever page you want based on that. – Carcigenicate Mar 05 '17 at 16:58
  • Why are you even supporting IE8? Microsoft doesn't even support it anymire – John Conde Mar 05 '17 at 16:59
  • @JohnConde If it's for school, it's understandable. I had to support 7 in a project I did a year ago. – Carcigenicate Mar 05 '17 at 17:00
  • @JohnConde I was just wondering, there could be someone from that 1% who uses internet explorer 8 who clicks on my website. – Dr Lemon Mar 05 '17 at 17:07
  • 1
    They are not worth the effort to support. So few users will use that browser that the effort put into supporting them isn't worth the cost. They know they are using an old obsolete browser and expect, and are used to, websites not supporting it. – John Conde Mar 05 '17 at 17:12

2 Answers2

0

You can try to detect the User-Agent with your preferred server-side language, or use JavaScript via the navigator.userAgent property.

However, maintaining an entire copy of your site just for IE8 seems a bit overkill - actually, I wouldn't recommend even making the extra effort to support IE8. For general use however, here's how to target different IE versions and deal with unsupported features:

Detecting IE

Fortunately, IE supports conditional comments, so you can use those to include different resources based on IE version:

<!--[if lt IE 9]>
    <link rel="stylesheet" href="url/to/ie8/stylesheet">
<!--<![endif]-->
<!--[if gt IE 8]><!-->
    <link rel="stylesheet" href="url/to/bootstrap">
<!--<![endif]-->

If you look closely, you can see that the last [if ...] statement is immediately closed and its content is not embedded in a comment. Since only IE understands conditional comments, other browsers will just ignore it and render your content in the last if (the one that isn't actually commented out). The syntax is rather ugly, but it's the easiest way to only target IE versions.

Checking missing features

If you need to make sure the code you use on your site works on all browsers, it's easier to simply make a list of browser features you're going to use and check if they are available instead of trying to make a different version for every quirky browser. Take a look at the idea of feature detection and polyfills, they might be a better approach to this problem in the future.

Hope this helps!

ppajer
  • 3,045
  • 1
  • 15
  • 22
-2

actually yes! but is there some way :

1. if browser = opera(example) (check user agent)=> redirect to other website(other page or host!)

2. if browser = opera => render other template 

See this :

//check is IE :
 if (preg_match('/MSIE\s(?P<v>\d+)/i', @$_SERVER['HTTP_USER_AGENT'], $B) && $B['v'] <= 8) {
    // Browsers IE 8 and below
} else {
    // All other browsers
}
Mohsen
  • 1,415
  • 1
  • 13
  • 26
  • Building multiple website to support different browsers is the *wrong* solution. – John Conde Mar 05 '17 at 17:12
  • This answers assumes they are using PHP. How do you know they are? – John Conde Mar 05 '17 at 17:13
  • User-agents can be spoofed and cannot be relied upon. – John Conde Mar 05 '17 at 17:13
  • yes! but I said about all of solutions! not best! so i write a code that work with user-agent that is best way! @JohnConde see [here](http://stackoverflow.com/questions/13252603/how-works-http-user-agent). – Mohsen Mar 05 '17 at 17:15
  • yes can be spoofed but finally we need data(browser name) from client that we can not truest it! In addition all of this is about UI! so actually not important that anybody fake it! @JohnConde – Mohsen Mar 05 '17 at 17:27