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

Best way to check for IE less than 9 in JavaScript without library

Javascript var ie = (function(){ var undef, v = 3, div = document.createElement(‘div’), all = div.getElementsByTagName(‘i’); while ( div.innerHTML = ‘<!–[if gt IE ‘ + (++v) + ‘]><i></i><![endif]–>’, all[0] ); return v > 4 ? v : undef; }()); You can then do: ie < 9 By James Panolsey from here: http://james.padolsey.com/javascript/detect-ie-in-js-using-conditional-comments

Use jQuery to detect whether a device can make telephone calls (supports “tel://” protocol)

I’m not sure about Android or BlackBerry, but iOS will automatically pick up telephone numbers and wrap them like so: <a href=”https://stackoverflow.com/questions/17345177/tel:xxx”>xxx</a>…so you could have a hidden <div> somewhere that contains a phone number like 1-800-555-5555, then, on page load do something like this: var isTelephone = $(“a[href*=’tel:’]”).length > 0; This may or may not … Read more

Distinguish Chrome from Safari using jQuery.browser

Since Sarfraz has not corrected his answer (thank you Sarfraz for pointing me in the correct direction), I will post functioning code here. var userAgent = navigator.userAgent.toLowerCase(); $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); // Is this a version of Chrome? if($.browser.chrome){ userAgent = userAgent.substring(userAgent.indexOf(‘chrome/’) +7); userAgent = userAgent.substring(0,userAgent.indexOf(‘.’)); $.browser.version = userAgent; // If it is chrome then jQuery … Read more

Detect Safari using jQuery

Using a mix of feature detection and Useragent string: var is_opera = !!window.opera || navigator.userAgent.indexOf(‘ OPR/’) >= 0; var is_Edge = navigator.userAgent.indexOf(“Edge”) > -1; var is_chrome = !!window.chrome && !is_opera && !is_Edge; var is_explorer= typeof document !== ‘undefined’ && !!document.documentMode && !is_Edge; var is_firefox = typeof window.InstallTrigger !== ‘undefined’; var is_safari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); Usage: if … Read more