您的位置:首页 > Web前端 > JavaScript

找了段滚轮缩放图片的JS代码

2008-09-16 16:27 477 查看
<script>

function imgzoom(o){

var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0)

o.style.zoom=zoom+'%';

return false;

}

var dragapproved=false

function drag_dropie(){

if (dragapproved==true){

document.all.showimage.style.pixelLeft=tempx+event.clientX-iex

document.all.showimage.style.pixelTop=tempy+event.clientY-iey

return false

}

}

function initializedragie(){

if (event.srcElement.parentElement.id=="showimage"){

iex=event.clientX

iey=event.clientY

tempx=showimage.style.pixelLeft

tempy=showimage.style.pixelTop

dragapproved=true

document.onmousemove=drag_dropie

}

}

if (document.all){

document.onmousedown=initializedragie

document.onmouseup=new Function("dragapproved=false")

}

</script>

<IMG> 中加上 onmousewheel="return imgzoom(this);" 就行了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: