browser-feature-detection

Detect viewport units (with modernizr or normal js) and serve appropriate stylesheet

房东的猫 提交于 2019-12-22 12:19:33
问题 I actually have an issue im trying to solve since 3 weeks. Im trying to test support for vw units and serve a seperate stylesheet when the browser doesnt support the unit I read the modernizr tutorials and am familiar with modernizr css detects but testing for vh units (viewport relative units) is something I didnt find on the net. So basically: Scenario 1: Browser supports vw unit then serve stylesheet A. Scenario 2: Browser doesnt support it then serve stylesheet B. I did find out that

Is there a way of detecting if the browser will freeze the DOM while scrolling?

守給你的承諾、 提交于 2019-12-22 08:49:53
问题 Is there a way of detecting if the browser will freeze the DOM or disable JavaScript while scrolling? It's known that some mobile browsers do this, and it effectively kills scrolling-based effects like parallax and animations. I'd like to effectively implement the following pseudocode without resorting to UA sniffing: if (!browserWillFreezeWhileScrolling) { initializeScrollingEffects(); } else { initializeFallbackScript(); // maybe unnecessary } From what I can see, Modernizr doesn't check it

/*@cc_on and IE6 detection

情到浓时终转凉″ 提交于 2019-12-21 17:01:41
问题 When researching JavaScript conditional comments for IE, I stumbled upon @cc_on. This seems to work. However, the wikipedia entry on conditional comments provides the following code for more robust IE detections, specifically IE6: /*@cc_on @if (@_jscript_version > 5.7) document.write("You are using IE8+"); @elif (@_jscript_version == 5.7 && window.XMLHttpRequest) document.write("You are using IE7"); @elif (@_jscript_version == 5.6 || (@_jscript_version == 5.7 && !window.XMLHttpRequest))

How do I programmatically detect how a browser handles window.close()?

徘徊边缘 提交于 2019-12-21 07:47:00
问题 Different web browsers handle the window.close() function differently. IE prompts the user for confirmation, while Firefox and Safari just fail to honor it unless the window was originally opened with Javascript and display a message saying as much in the console. A third party web application used internally in our organization that I support displays a 'close' button at the end of a wizard-like series of pages. This works well for IE, which is what the majority of our users use. However,

How to detect `focusin` support?

喜你入骨 提交于 2019-12-18 12:21:39
问题 Thanks to Perfection kills, we can use the following JavaScript to detect event support: function hasEvent(ev) { var elem = document.createElement('a'), type = 'on' + ev, supported = elem[type] !== undefined; if (!supported) { elem.setAttribute(type, 'return;'); supported = typeof elem[type] === 'function'; } elem = null; return supported; } This works for about the only time I need it: detecting mouseenter support; hasEvent('mouseenter') will return false in Chrome, Firefox, etc., as it

Detect if browser supports data uri scheme with iframes

你离开我真会死。 提交于 2019-12-18 06:31:26
问题 Internet Explorer does not support the data uri scheme for iframe urls (see http://msdn.microsoft.com/en-us/library/cc848897%28v=vs.85%29.aspx). Other browsers do. As browser detection is loaded with testing and future-proofing problems, I want to use feature detection to work around this issue. So: how can I detect whether or not a browser supports the data uri scheme for iframes? 回答1: This solution by Kevin Martin is tested and seems to be giving the correct result in IE, FF and Chrome:

Check if Firefox/Firefox OS/Firefox for Android

对着背影说爱祢 提交于 2019-12-13 04:59:24
问题 I'm working on a snippet for check if the browser is Firefox/Firefox OS/Firefox for Android. The method for check is the user agent with a little feature detection. I haven't found a better way with a complete feature detection that cover all the cases. The gist it's here: https://gist.github.com/Mte90/11087393 Any solution more professional? 回答1: As far as I know, there is no other way to do this, but I would suggest you do features detection when you need to use something specific, instead

In search for a library that knows to detect support for specific Audio Video format files

廉价感情. 提交于 2019-12-12 13:49:18
问题 I`m building a mobile-web app, and I am implementing Video & Audio tags. Apparently not all devices know to run all file formats. Modernizr knows to return to me the Codec, but how can I know if my file has this specific codec? I can identify the file extension or mim-type, but than I`ll need to compare the codec with the file extension, and maintain an array with this data, and this seems like a sisyphic task. What do you guys say? Any one knows on a good library that knows provide us with

Feature detection for ability to drop file over HTML file input

馋奶兔 提交于 2019-12-12 10:38:14
问题 Can we detect whether a browser supports dropping a file over an <input type="file" /> ? For example, this is possible in Chrome but not in IE8. Modernizr.draganddrop is a possibility but is it the right choice? I'm not adding any custom drag/drop event handlers. Update To verify Joe's answer here's a jQuery example that should stop the file drop. Verified in Chrome and Firefox. $yourFileInput.on('drop', function() { return false; // if Joe's explanation was right, file will not be dropped })

Feature detection for @supports?

醉酒当歌 提交于 2019-12-11 09:28:21
问题 How can I detect if a browser supports the CSS @supports feature? Since Internet Explorer and Safari don't support it, my web app doesn't know which styles to apply in those browsers. 回答1: Using pure CSS, you can sort of rely on the cascade to determine whether a browser understands @supports by making a @supports rule with a universally-supported declaration, such as a color declaration, and overriding another such rule that is declared globally: #test { color: red; } @supports (color: green