I think just about your only real option is to clear the property, grab the value after clearing it, then repeatedly set it until it no longer has that value, like this:
function setPrefixedValue(elm, prop, value) {
var prefixes = ['-moz-', '-webkit-', '-o-', '-ms-', '-khtml-'];
var i, v, starting;
// Clear
elm.style[prop] = "";
starting = elm.style[prop];
// Try raw first
try {
elm.style[prop] = value;
if (elm.style[prop] !== starting) {
console.log("No prefix");
return;
}
}
catch (e) {
}
// Try prefixes
for (i = 0; i < prefixes.length; ++i) {
v = prefixes[i] + value;
try {
elm.style[prop] = v;
if (elm.style[prop] !== starting) {
console.log("Prefix: " + prefixes[i]);
return;
}
}
catch (e2) {
}
}
console.log("Didn't find prefix");
}
// Usage
setPrefixedValue(someElement, "background", "linear-gradient(red, blue)");
Live Example | Source
Side note: I tested various versions of Chrome, Firefox, Opera, and IE. I didn't find a browser that appeared to support that linear-gradient
value, but required a prefix. Recent Chrome and Firefox; Opera 12.15; and IE10 all support it without any prefix; Opera 10.62, IE8, and IE9 didn't support it either prefixed or not. (For IE8 and 9, I think you need to use a filter instead.)