php-browser-detection icon indicating copy to clipboard operation
php-browser-detection copied to clipboard

Interner Explorer 11 example?

Open stephenmeehanuk opened this issue 2 years ago • 2 comments

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.

stephenmeehanuk avatar Jan 27 '22 19:01 stephenmeehanuk

Hi, just wondering if this is possible?

stephenmeehanuk avatar Feb 09 '22 16:02 stephenmeehanuk

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">';
}

ak56Lk avatar Feb 10 '22 10:02 ak56Lk