-2
ブラウザのサポートに基づいてイメージにフィルタを表示しようとしています。ブラウザが特定のCSSプロパティをサポートしているかどうかを確認する方法
ブラウザがjavascriptを使用してフィルタや--webkit-filterなどの特定のCSSプロパティをサポートしているかどうかを確認するにはどうすればよいですか?
あなたはtrue
またはfalse
var doSupport = CSS.supports('some CSS property', 'value');
を返す。しかし、キャッチがあるCSS.supports
を見ても、私は次の関数を使用していますが、そのは
isCSSStyleSupported: function(prop, value) {
// If no value is supplied, use "inherit"
value = arguments.length === 2 ? value : 'inherit';
// Try the native standard method first
if ('CSS' in window && 'supports' in window.CSS) {
return window.CSS.supports(prop, value);
}
// Check Opera's native method
if('supportsCSS' in window){
return window.supportsCSS(prop, value);
}
// Convert to camel-case for DOM interactions
var camel = prop.replace(/-([a-z]|[0-9])/ig, function(all, letter) {
return (letter + '').toUpperCase();
});
// Check if the property is supported
var support = (camel in el.style);
// Create test element
var el = document.createElement('div');
// Assign the property and value to invoke
// the CSS interpreter
el.style.cssText = prop + ':' + value;
// Ensure both the property and value are
// supported and return
return support && (el.style[camel] !== '');
},
可能な重複http://stackoverflow.com/questions/1342994/check-browser- css-property-support) –