JS实现放大、缩小及拖拽图片的方法【可兼容IE、火狐】

前端之家收集整理的这篇文章主要介绍了JS实现放大、缩小及拖拽图片的方法【可兼容IE、火狐】前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例讲述了JS实现放大、缩小及拖拽图片方法分享给大家供大家参考,具体如下:

0) { images1.style.zoom = (zoom+10) + "%"; }*/ //将图片放大,失去热点 height1 = images1.height; width1 = images1.width; images1.height = height1 * 1.1; images1.width = width1 * 1.1; } //还原 function realsize() { images1.style.zoom=100+"%"; images1.height = images2.height; images1.width = images2.width; divId.style.left=v_left; divId.style.top=v_top; } function featsize() { var width1 = images2.width; var height1 = images2.height; var width2 = 360; var height2 = 200; var h = height1 / height2; var w = width1 / width2; if (height1 < height2 && width1 < width2) { images1.height = height1; images1.width = width1; } else { if (h > w) { images1.height = height2; images1.width = width1 * height2 / height1; } else { images1.width = width2; images1.height = height1 * width2 / width1; } } block1.style.left = 0; block1.style.top = 0; } //鼠标滚轮放大缩小 function bbimg(o) { /*var eleLeft; var eleTop; if(document.documentElement){ eleLeft = document.documentElement.scrollLeft; eleTop = document.documentElement.scrollTop; } else{ eleLeft = document.body.scrollLeft; eleTop = document.body.scrollTop; } v_left+=eleLeft; v_top+=eleTop; //divId.style.left=v_left; //divId.style.top=v_top; alert(document.documentElement.scrollTop +"----xxx"+document.body.scrollTop+window.pageyoffset);*/ var zoom = parseInt(o.style.zoom,10) || 100; zoom += event.wheelDelta / 12; if (zoom > 0) { o.style.zoom = zoom + "%"; } return false; }

更多关于JavaScript相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》及《

希望本文所述对大家JavaScript程序设计有所帮助。

猜你在找的JavaScript相关文章