javascript实现图片旋转

来源:互联网 发布:sql删除字段 编辑:程序博客网 时间:2024/04/29 16:04

<body>
<img src="2.jpg"><br>
<input type=button value="放大" onclick="large()">
<input type=button value="缩小" onclick="small()">
<input type=button value="旋转" onclick="rotate()">
<input type=button value="打印" onclick="printPic()">
</body>
<script>
var img=document.getElementsByTagName('img')[0];
function small()
{
img.width=img.width*0.5;
img.height=img.height*0.5;
}
function large()
{
img.width=img.width*2;
img.height=img.height*2;
}
function rotate()
{
//rotation: 1 旋转90度 ;2 旋转180度 ;3 旋转270度
img.style.filter='progid:DXImageTransform.Microsoft.BasicImage(rotation=1)'
}
function printPic()
{
window.print();
}
</script>

原创粉丝点击