2014-12-05 49 views
1

以下代碼適用於所有瀏覽器,但不適用於Internet Explorer,即使我使用了MsTransform,但仍然無法正常工作。旋轉功能在IE中不起作用

<!DOCTYPE html> 
<html> 
<head> 
<script> 
var looper; 
var degrees = 0; 
function rotateAnimation(el,speed){ 
var elem = document.getElementById(el); 
    elem.style.WebkitTransform = "rotate("+degrees+"deg)"; 
    elem.style.MozTransform = "rotate("+degrees+"deg)"; 
    elem.style.MsTransform = "rotate("+degrees+"deg)"; 
    elem.style.OTransform = "rotate("+degrees+"deg)"; 
looper = 
setTimeout(function() 
{ 
    rotateAnimation(el,speed) 
},speed); 

    degrees++; 
    if(degrees > 359){ 
     degrees = 1; 
    } 
} 
</script> 
</head> 
<body> 
<img id="img1" src="cog1.png" alt="cog1"> 
<script>rotateAnimation("img1",30);</script> 
</body> 
</html> 
+0

與'elem.style.msTransform'嘗試,並添加'elem.style.transform' – guest271314 2014-12-05 16:19:41

回答

0

嘗試小寫:

elem.style.msTransform = "rotate("+degrees+"deg)"; 

Working Link

+0

謝謝:)它的工作 – 2014-12-05 16:37:17