Yes, there is a way. Below is a demo, explanation below. There are some very important caveats , so make sure you read.
The following code checks to see if the browser can animate between two values.
Code
jsFiddle demo .
function isAnimationSupported(property, from, to, element) { var doc = document.documentElement, style = doc.appendChild(document.createElement("style")), rule = [ 'capTest{', '0%{', property, ':', from, '}', '100%{', property, ':', to, '}', '}' ].join(''), propCamel = property.toCamelCase(), prefixes = 'moz ms o webkit '.split(' '),
How to use
Mandatory arguments for this are the property to animate both the start and end values ββthat it must take. If you wish, you can pass an element with other initial stylesets, for example. position: absolute . (The function clones the element, so you can pass the nodes from the document and they will not be changed.) If you do not go through any elements, the animation is tested on a div with any default styles used by UA.
How it works
The keyframe animation rule is added to the dummy style sheet, with the original frame set to from , and the last frame set to . This animation applies to an element. Then we check the computed style for the animated property to see if it is different when the animation starts from the original frame compared to when it starts from the final frame.
The reason for this is that the animation properties for both transitions and keyframe animations are the same, and the browser will only apply keyframe values ββif the property supports animation.
Cautions (read before use, some of them are nasty!)
There are several inconsistencies in how browsers handle animations. I worked several of them in the most reliable way; however, some of them are intractable.
In particular, Firefox increases position values ββ(for example, left ) on static elements, while others (for example, Webkit and Opera) do not. In fact, the item does not move, but the value of this property is updated. Thus, you will get different results between browsers if you try to animate the position value without passing an element that is not statically located.
Most recent versions of major browsers that support CSS transitions also support CSS keyframes, although some older versions support the first, but not the last. (E.g. Opera 11.)
Finally, if I were to do it more elegantly, I would use prefixfree to determine the correct prefix to use directly; I am currently testing an array of prefixes, starting with a version without a prefix.