How can I target only Internet Explorer 11 with JavaScript?
问题 What's the least error-prone way to target just IE11 with JavaScript? Note: This should really only be done for analytics or informing the user what browser they're using. For everything else, there's feature detection. 回答1: The User-agent string for IE 11 is currently this one : Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv 11.0) like Gecko Windows 10 example: Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko Which means your can simply test, for versions 11.xx, var isIE11 =