Home > Web Front-end > JS Tutorial > body text

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

花姐姐
Release: 2020-05-06 13:39:33
forward
2097 people have browsed it

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);
Copy after login

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!

Related labels:
js
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!