鼠标通过滚轮缩放图片尺寸的js代码

<script>
function onWheelZoom(obj){
zoom = parseFloat(obj.style.zoom);
tZoom = zoom + (event.wheelDelta>0 ? 0.05 : -0.05);
if(tZoom<0.1 ) return true;
obj.style.zoom=tZoom;
return false;
}
function small(){
var image0 = document.getElementById('image0');
var height1=image0.height;
var width1=image0.width;
image0.height=height1/1.1;
image0.width=width1/1.1;
}

function big(){
var image0 = document.getElementById('image0');
var height1=image0.height;
var width1=image0.width;
image0.height=height1*1.1;
image0.width=width1*1.1;
}
</script>
<img src="1.jpg" name="image0" id="image0" style="zoom:1;" onmousewheel='return onWheelZoom(this)' />
<input type="button" name="Submit" value="Enlarge" onclick="big()" />
<input type="button" name="Submit2" value="Narrow" onclick="small()" />

posted on 2009-11-09 11:08  画一个圆圈  阅读(199)  评论(0编辑  收藏  举报

导航