css - Detect support for -webkit-filter with javascript -
using javascript, how detect if browser supports webkit filters?
based on info provided @ default css filter values brightness , contrast, have tried following , few of other default values:
if (window.matchmedia && window.matchmedia("( -webkit-filter:opacity(1) )").matches) { alert("supported"); }else{ alert("not supported"); }
an relatively easy way test whether css property supported following:
- create element
- apply css in question element
- read value - if same value set in step 2, supported, otherwise not
js:
var e = document.queryselector("img"); e.style.webkitfilter = "grayscale(1)"; if(window.getcomputedstyle(e).webkitfilter == "grayscale(1)"){ "supported!"; }
Comments
Post a Comment