天天看点

javascript实现图片旋转

<body>

<img src="2.jpg"><br>

<input type=button value="放大" οnclick="large()">

<input type=button value="缩小" οnclick="small()">

<input type=button value="旋转" οnclick="rotate()">

<input type=button value="打印" οnclick="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>

继续阅读