Reputation: 413
Using JavaScript, how do you detect if a browser supports webkit filters?
Based on the info provided at Default CSS filter values for brightness and contrast, I have tried the following and a few of the other default values:
if (window.matchMedia && window.matchMedia("( -webkit-filter:opacity(1) )").matches) {
alert("supported");
}else{
alert("not supported");
}
Upvotes: 3
Views: 1431
Reputation: 51191
An relatively easy way to test whether a css property is supported is the following:
js:
var e = document.querySelector("img");
e.style.webkitFilter = "grayscale(1)";
if(window.getComputedStyle(e).webkitFilter == "grayscale(1)"){
"supported!";
}
Upvotes: 7