js不让电脑端浏览器缩放网页-LMLPHP

尝试过监控键盘和滚轮事件,阻止默认事件,在不同浏览器里表现不一

   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);
登录后复制

推荐学习:JavaScript

以上就是js不让电脑端浏览器缩放网页的详细内容,更多请关注Work网其它相关文章!

08-24 05:10