Question

So I'm looking to get the value of a CSS property that the browser doesn't support. This is something I'd like to use to create a polyfill, but I need to know the value of the property at any given time.

Here's a test file with all the methods I've tried so far. Bascially, given the following:

#element {
    transform: rotate(2deg);
}

I'd like to be able to, via JavaScript, get the value rotate(2deg) regardless of whether or not the browser supports it. Is this possible? And if so, is there a preformant way to do it (I will need to do this a lot in older browsers)?

Some preferences if it is possible:

  • Would prefer to do this from an element, instead of looping through a stylesheet's rules
  • Need to support IE 7 at least (or have methods to do so)
  • Shouldn't take 2 seconds to calculate. I'd like something that will preform decently

No correct solution

OTHER TIPS

I was able to retrieve the value in your demo with jQuery in Firefox:

var match = $( 'style' ).html().match( /transform:\s*(.+);?/ );
var value = match ? match[1] : '';

Live demo: http://jsfiddle.net/fnF2V/5/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top