//缩放类  兼容性良好
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")

相关文章:

  • 2021-10-06
  • 2018-07-03
  • 2021-05-13
  • 2021-10-09
  • 2021-07-28
  • 2021-11-12
  • 2022-01-01
  • 2021-12-03
猜你喜欢
  • 2021-12-04
  • 2022-01-18
  • 2021-11-12
  • 2021-04-21
  • 2021-10-06
  • 2021-10-29
  • 2021-04-18
相关资源
相似解决方案