Get the DXImageTransform.Microsoft.Matrix value fr

2019-09-20 12:43发布

问题:

Here is my css code:

#pic-1 {
    z-index: 1;
    -webkit-transform: rotate(-10deg);
    -moz-transform: rotate(-10deg);
    -o-transform: rotate(-10deg);
    transform: rotate(-10deg);
    -ms-transform: rotate(-10deg); 
   filter: progid:DXImageTransform.Microsoft.Matrix(
            M11=0.9848077530122081,
            M12=0.17364817766692991,
            M21=-0.17364817766692991,
            M22=0.9848077530122081,
            SizingMethod='auto expand');

}

I want to get the filter matrix M11 value from this class. In this case I tried:

console.log(document.getElementById("pic-1").filters.item(0).M11);

and several other variations, but I get nothing. Anybody knows how to get the M11 value from node n? Basically I need this to calculate the rotation in degrees in IE7.

回答1:

Check this link in IE- http://jsfiddle.net/qcgxR/2/

Script

object.filters.filters.item("DXImageTransform.Microsoft.Matrix").M11 = value;

Eg:-

document.getElementById("mydog").filters.item("DXImageTransform.Microsoft.Matrix").M11=.5;


回答2:

You could fetch the property and match it against a regexp: http://jsfiddle.net/Hacv6/3/.

var filter = document.getElementById("pic-1").currentStyle.filter,
    regexp = /M11=([^,]+),/,
    match = filter.match(regexp);

alert(match[1]);