JavaScript控制图片360度旋转代码 时间:2020-05-13 人气:0 JavaScript控制图片360度旋转代码 <script language="javascript"> var isIE = (document.uniqueID)?1:0; var i=1; function rotate(image) { var object = image.parentNode; if(isIE){ image.style.filter="progid:dXImagetransform.Microsoft.basicImage(rotation="+i+")"; i++; if(i>4) {i=1}; } else{ try{ var canvas = document.createElement('canvas'); if(canvas.getContext("2d")) { object.replaceChild(canvas,image); var context = canvas.getContext("2d"); context.translate(176, 0); context.rotate(Math.PI*0.5); context.drawImage(image,0,0); } }catch(e){} } } </script> [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] 加载全部内容