<HTML>
<head>
<title>縮放圖片</title>
<script language=JavaScript>
var h,w; //h:高 w:寬
function getImgSize() { //取得圖片大小
h=document.img1.height
w=document.img1.width
}
function restore() { //還原
document.img1.height=h;
document.img1.width=w;
}
function zoomIn() { //放大
document.img1.height *=1.2;
document.img1.width *=1.2;
}
function zoomOut() { //縮小
document.img1.height /=1.2;
document.img1.width /=1.2;
}
</script>
</head>
<BODY onLoad="getImgSize()">
<p align=center>
<form>
<input type=button onclick="zoomIn()" value="Zoom In (+)">
<input type=button onclick="restore()" value="原始大小">
<input type=button onclick="zoomOut()" value="Zoom Out (-)">
<br>
<img border="0" src="untitled.jpg" name="img1" width="338" height="338"></p>
</BODY>
</HTML>