Get the DXImageTransform.Microsoft.Matrix value from Javascript

允我心安 提交于 2019-12-12 07:01:25

问题


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]);


来源:https://stackoverflow.com/questions/9342002/get-the-dximagetransform-microsoft-matrix-value-from-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!