天天看點

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>

繼續閱讀