禁止ctrl 加 鼠标滚轮控制网页缩放

 //  禁止ctrl 加 鼠标滚轮控制网页缩放
        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 });

        // 禁止ctrl 加 ‘+’ ‘-’ 控制网页缩放
        window.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);

你可能感兴趣的:(禁止ctrl 加 鼠标滚轮控制网页缩放)