当前位置:网站首页>通过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});
边栏推荐
- MW: 3400 4-Arm PEG-DSPE four-arm-polyethylene glycol-phospholipid a saturated 18-carbon phospholipid
- Websocket协议解析与QT代码示例
- Unity转微信小游戏与JS交互
- Cholesterol-PEG-NHS NHS-PEG-CLS cholesterol-polyethylene glycol-active ester can modify small molecular materials
- MySQL master-slave switching steps
- 2022 SQL big factory high-frequency practical interview questions (detailed analysis)
- 链表理论基础
- MySQL free installation download and configuration tutorial
- Introduction to CLS-PEG-FITC Fluorescein-PEG-CLS Cholesterol-PEG-Fluorescein
- Cholesterol-PEG-Acid CLS-PEG-COOH Cholesterol-Polyethylene Glycol-Carboxyl Modified Peptides
猜你喜欢

在 AWS 上从零开始设置 Incredibuild 构建系统

【Rhapsody学习笔记】2:Count Down

The content of the wangeditor editor is transferred to the background server for storage

Four common ways of POST to submit data

UR3机器人雅克比矩阵

Chemical Reagent Phospholipid-Polyethylene Glycol-Amino, DSPE-PEG-amine, CAS: 474922-26-4

Pytorch study notes 7 - processing input of multi-dimensional features

Learn how to get a database connection with JDBC

2021年开发人员的绊脚石:构建时间长

2021-09-30
随机推荐
CSDN上markdown编写的一些便捷操作
C语言静态变量static
Remote file xxx is mapped to the local path xxx and can‘t be found. You can continue debugging....
Cholesterol-PEG-Azide CLS-PEG-N3 胆固醇-聚乙二醇-叠氮 MW:3400
Natural language processing related list
Research reagents Cholesterol-PEG-Maleimide, CLS-PEG-MAL, Cholesterol-PEG-Maleimide
虚拟机查看端口号进程
[Solved] ssh connection report: Bad owner or permissions on C:\\Users/XXX/.ssh/config
DSPE-PEG-Azide DSPE-PED-N3 Phospholipid-Polyethylene Glycol-Azide Lipid PFG
2021年开发人员的绊脚石:构建时间长
【Rhapsody学习笔记】2:Count Down
堆和栈的区别
Redis-Hash
Detailed explanation of mysql transaction principle
力扣151. 颠倒字符串中的单词
力扣.剑指offer05.替换空格
Word vector - demo
CAS:474922-22-0 Maleimide-PEG-DSPE Phospholipid-Polyethylene Glycol-Maleimide Brief Description
超详细!!!让你通透数组!!!初学复习不迷路!!
mobaxterm 编码问题解决