当前位置:网站首页>通过js禁止ctrl+滚轮放缩浏览器页面,禁止用手势放大
通过js禁止ctrl+滚轮放缩浏览器页面,禁止用手势放大
2022-07-31 05:18:00 【weixin_39945506】
禁止ctrl + ‘+’ 和ctrl + '-'
ctrl + + 放大, ctrl + - 缩小
61
107 +
109 -
173 静音
187 =+
189 -_
代码:
document.addEventListener(‘keydown’, function (event) {
if ((event.ctrlKey === true || event.metaKey === true)
&& (event.keyCode === 61 || event.keyCode === 107
|| event.keyCode === 173 || event.keyCode === 109
|| event.keyCode === 187 || event.keyCode === 189)) {
event.preventDefault();
}
}, false);
ctrl+滚轮缩放
不加passive: false,还是会执行缩放
document.addEventListener(‘mousewheel’, function (e) {
e = e || window.event;
if ((e.wheelDelta && event.ctrlKey) || e.detail) {
event.preventDefault();
}
}, {passive: false}
);
禁止手势缩放
document.documentElement.addEventListener(‘touchstart’, function (event) {
if (event.touches.length > 1) {
event.preventDefault();
}
}, {passive:false});
// 禁止双击放大
let lastTouchEnd = 0;
document.documentElement.addEventListener(‘touchend’, function (event) {
var now = Date.now();
if (now - lastTouchEnd <= 300) {
event.preventDefault();
}
lastTouchEnd = now;
}, {passive:false});
边栏推荐
- Getting Started with MySQL: The Case Statement Works Well
- DSPE-PEG-COOH CAS:1403744-37-5 磷脂-聚乙二醇-羧基脂质PEG共轭物
- CAS: 1403744-37-5 DSPE-PEG-FA Phospholipid-Polyethylene Glycol-Folic Acid for Scientific Research
- Cholesterol-PEG-Acid CLS-PEG-COOH Cholesterol-Polyethylene Glycol-Carboxyl Modified Peptides
- 常见网络攻击与防御方法
- Pytorch study notes 10 - detailed explanation of convolutional neural network and application of multi-classification task of mnist dataset
- The array technique, my love
- 【Rhapsody学习笔记】2:Count Down
- CLS-PEG-FITC Fluorescein-PEG-CLS 胆固醇-聚乙二醇-荧光素简介
- Chemical Reagent Phospholipid-Polyethylene Glycol-Amino, DSPE-PEG-amine, CAS: 474922-26-4
猜你喜欢

Learning and understanding of ROS service programming

DingTalk Enterprise Internal-H5 Micro Application Development

Learn how to get a database connection with JDBC

Cholesterol-PEG-Thiol CLS-PEG-SH 胆固醇-聚乙二醇-巯基
![[Solved] ssh connection report: Bad owner or permissions on C:\\Users/XXX/.ssh/config](/img/53/8b5a12e7ed551dca52ada5dbb5d6b5.png)
[Solved] ssh connection report: Bad owner or permissions on C:\\Users/XXX/.ssh/config

【Rhapsody学习笔记】1:Hello World

DSPE-PEG-Azide DSPE-PED-N3 磷脂-聚乙二醇-叠氮脂质PFG

ImportError: cannot import name ‘Xxxx‘ from partially initialized module ‘xx.xx.xx‘

力扣刷题之排序链表

mPEG-DMPE 甲氧基-聚乙二醇-双肉豆蔻磷脂酰乙醇胺用于形成隐形脂质体
随机推荐
【Rhapsody学习笔记】3:Dishwasher
十分钟教你玩转分支语句!!!!!小白速进,新手福利!!
DSPE-PEG-COOH CAS: 1403744-37-5 Phospholipid-polyethylene glycol-carboxy lipid PEG conjugate
Cholesterol-PEG-Amine CLS-PEG-NH2 Cholesterol-Polyethylene Glycol-Amino Research Use
Cholesterol-PEG-NHS NHS-PEG-CLS cholesterol-polyethylene glycol-active ester can modify small molecular materials
化学试剂磷脂-聚乙二醇-氨基,DSPE-PEG-amine,CAS:474922-26-4
解决nx安装 jtop问题
When solving background-size:cover, the picture is covered but not displayed completely?
Three methods of accessing image pixels in opencv
Wangeditor rich text editor to upload pictures and solve cross-domain problems
C语言知识点(二)
wangeditor编辑器内容传至后台服务器存储
Remote file xxx is mapped to the local path xxx and can't be found. You can continue debugging....
vs2022 xlua 集成第三方库编译报错Generator Visual Studio 15 2017 could not find any instance of Visual Studio.
Four common ways of POST to submit data
虚拟机查看端口号进程
多线程截取视频为每帧
Cholesterol-PEG-Thiol CLS-PEG-SH Cholesterol-Polyethylene Glycol-Sulfhydryl
滑动窗口法
Unity软件中UGUI和NGUI的多语言开发