js(vue)中 禁止ctrl + 鼠标滚轮页面缩放
<script>document.addEventListener('keydown', function (event) {if ((event.ctrlKey === true || event.metaKey === true)&& (event.which === 61 || event.which === 107|| event.which === 173 |
·
<script>
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);
// Chrome IE 360
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 });
</script>
- vue中直接放到index.htm
Tips:【小程序云开发】中高级前端面试题库(源码:小程序中联系我哟)。
---------- 创作不易,感谢大家,请多多支持!
l
更多推荐
已为社区贡献16条内容
所有评论(0)