找了段滚轮缩放图片的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);" 就行了
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);" 就行了
相关文章推荐
- 鼠标通过滚轮缩放图片尺寸的js代码
- JS实现鼠标滚轮缩小放大拖动图片代码
- JS控制图片等比例缩放的示例代码
- js 图片缩放特效代码
- js 鼠标滚轮缩放图片
- 原生JS写的一个书架式的图片缩放滚动展示特效代码
- js 图片等比例缩放代码
- 按比例缩放图片的js代码
- js实现鼠标滚轮控制图片缩放效果的方法(转)
- JS 图片缩放效果代码
- js实现鼠标滚轮控制图片缩放效果的方法
- JS 图片缩放效果代码
- js图片等比缩放程序代码
- 鼠标滚轮缩放图片(js)
- js 图片缩放(按比例)控制代码
- Magnifier.js - 支持鼠标滚轮缩放的图片放大镜效果
- 关于图片按比例自适应缩放的js代码
- JS实现按比例缩放图片的方法(附C#版代码)
- 牛掰的图片等比缩放js代码