Check if user is using IE
Instantly detect Internet Explorer:
This handy function weeds out IE by probing the navigator.userAgent
for unique IE identifiers.
Precise IE detection
Let's face it, detecting IE has its potholes. And by potholes, I mean compatibility modes and deceiving user agents. To tackle this, we've got the steadfast document.documentMode
, an IE-only property:
Tailor web content for IE
So, you're going the extra mile for your IE users. Fancy! We can enhance their visit by customising functionality and design. Add an 'ie' class to the HTML element allowing for specific styles:
With your SCSS or CSS:
For functional delighters, use conditional statements to orchestrate IE-only scripts:
A pro tip—IE doesn’t understand @supports
, so you'll need to draft fallbacks:
Going beyond IE detection
Browser detection with navigator.userAgent
is just the trailer. For a deep dive, consider feature detection libraries like Modernizr. Offering a detailed lowdown on the browser's abilities, they're unmissable for rock-solid, cross-browser applications.
Oh, did you hear? Edge switched teams to Chromium. Keep your fingers on the pulse—check the Microsoft support page for updates on user agents and the browser story.
Mastering responsive design for IE
When catering to IE users, you'll often encounter hurdles due to the inadequate CSS support in IE:
- Flexbox: The IE10 and IE11 implementation isn't standard. You'll have to dial in some prefixes.
- Media Queries: IE9 doesn't understand media queries; write a separate stylesheet for IE9 on down.
- Gradients: IE9 is supportive, but the syntax differs from the CSS standard.
Apply the principle of progressive enhancement so that your site, though unsophisticated in IE, remains operable and affords a good user experience.
Was this article helpful?