php-browser-detection
php-browser-detection copied to clipboard
Interner Explorer 11 example?
Hi
This script looks very useful, I was wondering could you show an example of how it could be implemented to serve an alternative CSS file for IE11?
I'm using Tailwind CSS, which doesn't support IE11. I'd like to be able to use Tailwind for modern browsers and fall back to ie11.css if IE11 is detected.
// If IE11 load this
<link rel="stylesheet" href="/css/ie11.css">
// else use Tailwind
<link rel="stylesheet" href="/css/tailwind.css">
Hope you can help.
Hi, just wondering if this is possible?
You can use this script only on server side. You can do something like that:
$BrowserDetection = new BrowserDetection();
$browser = $BrowserDetection->getBrowser($_SERVER['HTTP_USER_AGENT']);
if ($browser['browser_name'] === 'Internet Explorer') {
echo '<link rel="stylesheet" href="/css/ie11.css">';
}
else {
echo '<link rel="stylesheet" href="/css/tailwind.css">';
}