<script language="javascript"><!--
////写入正方形的层和容器,可以另外在html中创建。不过注意id=aDiv
document.write('<div style="position: relative; top: 0; left: 200; width: 75; height: 75;">'
+'<div id="aDiv" style="position: absolute; width: 50; height: 50; background-color: silver; border: 1 solid gray">'
+'<table border="0" cellpadding="0" cellspacing="0" width="{bfb}" height="{bfb}">'
+'<tr><td align="center" valign="middle">'
+'<p style="font-face: tahoma, arial, helvetica; font-size: 10px"><img src=http://www.jyzp.org/images/user9_16x16.gif>Spin!!'
+'</td></tr>'
+'</table>'
+'</div>'
+'</div>')///创建和运用滤镜
function rotate(name, angle){
//将角度转变成弧度
var rad = degToRad(angle);
//计算弧度的cos和sin值
costheta = Math.cos(rad);
sintheta = Math.sin(rad);//创建对象
var el = document.getElementById(name);
if(el) {
//应用滤镜
el.style.filter = "progid:DXImageTransform.Microsoft.Matrix()";
//设置滤镜的属性值
el.filters.item("DXImageTransform.Microsoft.Matrix").SizingMethod = "auto expand";
el.filters.item("DXImageTransform.Microsoft.Matrix").FilterType = "bilinear"; //运用旋转滤镜
el.filters.item("DXImageTransform.Microsoft.Matrix").M11 = costheta;
el.filters.item("DXImageTransform.Microsoft.Matrix").M12 = -sintheta;
el.filters.item("DXImageTransform.Microsoft.Matrix").M21 = sintheta;
el.filters.item("DXImageTransform.Microsoft.Matrix").M22 = costheta;
}
}//使角度转起来
var angle = 0;
function doRotate() {
//检查并确保角度值在0到360之间
if(angle>360) angle-=360;
//使角度增加
angle+=15;//do rotation
rotate("aDiv",angle);//定位旋转中心
var el = document.getElementById("aDiv")
el.style.top = 25 - (el.offsetHeight/2);
el.style.left = 25 - (el.offsetWidth/2);//循环
//setTimeout("doRotate();",10);
}//角度变弧度函数
var pi = Math.PI;
function degToRad(x) { return ( x/(360/(2*pi)) ); }
function radToDeg(x) { return ( x*(360/(2*pi)) ); }
doRotate()
//--></script>
**这段代码是关于矩阵滤镜。如果只是静态的使层里的内容转过一个角度的话是不需要循环(settimeout)的。