//缩放类 兼容性良好
var zoomClass = function(o){
if (typeof(o) == "string")
o = document.getElementById(o);
if (document.attachEvent)
o.attachEvent("onmousewheel", func);
else
o.addEventListener("DOMMouseScroll", func, false);
function func(e){
if (e.target) {
var oWidth = e.target.width;
var width = e.target.width + e.detail * 12;
var height = oWidth / (width - oWidth);
height = e.target.height / height;
height = e.target.height + height;
if (width > 0 && height > 0) {
e.target.width = width;
e.target.height = height;
}
}
else {
e = window.event;
var currentZoom = parseInt(o.style.zoom, 10) || 100;
currentZoom += event.wheelDelta / 12;
if (currentZoom > 0)
o.style.zoom = currentZoom + '%';
}
return false;
}
}
</script>
使用方法 zoomClass("objId")