javascript 网页放大 js控制网页缩放_firefox


禁止滑轮:

window.addEventListener('mousewheel', function(event){
        if (event.ctrlKey === true || event.metaKey) {
              event.preventDefault();
        }
      },{ passive: false});

      //firefox
      window.addEventListener('DOMMouseScroll', function(event){
          if (event.ctrlKey === true || event.metaKey) {
                event.preventDefault();
          }
      },{ passive: false});

禁止+、- :

window.onload = function() {
  document.addEventListener('keydown', function (event) {
        if ((event.ctrlKey === true || event.metaKey === true)
            && (event.which === 61 || event.which === 107
            || event.which === 173 || event.which === 109
            || event.which === 187  || event.which === 189))
        {
            event.preventDefault();
        }
    }, false);
}

完整代码:

<script>
//luwenjie hualun
      window.addEventListener('mousewheel', function(event){
        if (event.ctrlKey === true || event.metaKey) {
              event.preventDefault();
        }
      },{ passive: false});

      //firefox
      window.addEventListener('DOMMouseScroll', function(event){
          if (event.ctrlKey === true || event.metaKey) {
                event.preventDefault();
          }
      },{ passive: false});
//+_
window.onload = function() {
  document.addEventListener('keydown', function (event) {
        if ((event.ctrlKey === true || event.metaKey === true)
            && (event.which === 61 || event.which === 107
            || event.which === 173 || event.which === 109
            || event.which === 187  || event.which === 189))
        {
            event.preventDefault();
        }
    }, false);
}


</script>

看个轮廓就可以了哈,反正两个都不会缩放,今天就到这里!

javascript 网页放大 js控制网页缩放_javascript_02