Home  >  Article  >  Web Front-end  >  js does not allow the computer browser to zoom the web page

js does not allow the computer browser to zoom the web page

花姐姐
花姐姐forward
2020-05-06 13:30:542038browse

js does not allow the computer browser to zoom the web page

I have tried monitoring keyboard and wheel events and blocking default events, but the performance is different in different browsers

   document.addEventListener('DOMContentLoaded', function (event) {            //chrome浏览器
            document.body.style.zoom = 'reset';            document.addEventListener('keydown', function (e) {                if ((e.ctrlKey === true || e.metaKey === true) &&
                    (e.which === 61 || e.which === 107 || e.which === 173 || e.which === 109
                        || e.which === 187 || e.which === 189)) {
                    e.preventDefault();
                }
            }, false);            document.addEventListener('mousewhell DOMMouseScroll', function (e) {                if (e.ctrlKey === true || e.metaKey === true) {
                    e.preventDefault();
                }
            }, false);
        }, false);

Recommended learning: JavaScript

The above is the detailed content of js does not allow the computer browser to zoom the web page. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete