Is there a good way to detect if the user’s browser is Internet Explorer using jQuery?
I have an issue with PNG graphics using IE and want to swap them for GIF’s only if the user is viewing the site with IE.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can using
$.browser, yes, but it’s a bad idea to use browser detection:A better option for instance would be
$.supportwhich is feature detection, like this:$.support.opacityis false in browsers that don’t supportopacityin styling (though IE 7-8 handle transparent PNGs file, so this still isn’t ideal, depending on what you’re after…personally I think you’d be giving IE 7/8 users a sub-optimal experience).What you should really do is target IE6 which doesn’t support transparent PNGs (without an alpha filter), like this: