How to target Edge browser with javascript

Try to detect features instead of a specific browser. It’s more future-proof. Only rarely should you use browser detection. With that out of the way: one option is to use a library (there are many intricacies to User Agent strings), or alternatively to parse window.navigator.userAgent manually. Using a parser library # https://github.com/faisalman/ua-parser-js. var parser = … Read more

Javascript IE detection, why not use simple conditional comments? [duplicate]

James Padolsey put a little snippet on GitHub that I’ll quote here: // ———————————————————- // A short snippet for detecting versions of IE in JavaScript // without resorting to user-agent sniffing // ———————————————————- // If you’re not in IE (or IE version is less than 5) then: // ie === undefined // If you’re in … Read more

What’s the replacement for $.browser

Based on jQuery migration plugin , I found this. jQuery.uaMatch = function( ua ) { ua = ua.toLowerCase(); var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || /(webkit)[ \/]([\w.]+)/.exec( ua ) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || /(msie) ([\w.]+)/.exec( ua ) || ua.indexOf(“compatible”) < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || []; return { browser: match[ … Read more

Browser detection

if (Request.Browser.Type.Contains(“Firefox”)) // replace with your check { … } else if (Request.Browser.Type.ToUpper().Contains(“IE”)) // replace with your check { if (Request.Browser.MajorVersion < 7) { DoSomething(); } … } else { }

How do you detect support for VML or SVG in a browser

I’d suggest one tweak to crescentfresh’s answer – use document.implementation.hasFeature(“http://www.w3.org/TR/SVG11/feature#BasicStructure”, “1.1”) rather than document.implementation.hasFeature(“http://www.w3.org/TR/SVG11/feature#Shape”, “1.0”) to detect SVG. WebKit is currently very picky about reporting features, and returns false for feature#Shape despite having relatively solid SVG support. The feature#BasicStructure alternative is suggested in the comments to https://bugs.webkit.org/show_bug.cgi?id=17400 and gives me the answers I expected on … Read more