javascript access of css transforms for opera and ie

Problem

i am making this global function which will simply change an element's transform property. This is what i have.

function transform(element, value) {
    if(element.style.webkitTransform) element.style.webkitTransform = value;
    else if(element.style.MozTransform) element.style.MozTransform = value;
}

I also want to add opera and ie to the above function. i have opera running with me so i can test opera but i dont have ie 9. Also i cant figure out how can i access opera's either. Can anyone please help?

I want something like this

function transform(element, value) {
    if(element.style.webkitTransform) element.style.webkitTransform = value;
    else if(element.style.MozTransform) element.style.MozTransform = value;
    else if(element.style.msTransform) element.style.msTransform = value;
    else if(element.style.oTransform) element.style.oTransform = value;
}
Problem courtesy of: Achshar

Solution

You can always just set them all. The other browsers will ignore styles they cannot understand.

function transform(element, value) {
    element.style.webkitTransform = value;
    element.style.MozTransform = value;
    element.style.msTransform = value;
    element.style.OTransform = value;
}
Solution courtesy of: seth.miller

Discussion

With older versions of Opera, based on Presto engine, you should do forced precision to reduce the side effects of the 'early' implementation of CSS 2D transforms, such as:

var action = "scale(" + value.toPrecision(4) + ")";
element.style.transform = action;
element.style.oTransform = action;

I don't believe this has negative impact on modern implementations.

Discussion courtesy of: Roger

This recipe can be found in it's original form on Stack Over Flow.