当前位置:网站首页>JS disable browser default events
JS disable browser default events
2022-06-25 17:13:00 【Come and play games with people】
No use tab Key
_initStopTabKeycode () {
window.addEventListener('keydown', event => {
if (event.keyCode === 9) {
event.preventDefault()
}
})
}
PC End prohibit browser from zooming in and out
_initNoScroll () {
const keyCodeMap = {
// 91: true, // command
61: true,
107: true, // The keypad +
109: true, // The keypad -
173: true, // firefox - Number
187: true, // +
189: true, // -
};
// Cover ctrl||command + ‘+’/‘-’
document.onkeydown = function (event) {
const e = event || window.event;
const ctrlKey = e.ctrlKey || e.metaKey;
if (ctrlKey && keyCodeMap[e.keyCode]) {
e.preventDefault();
} else if (e.detail) {
// Firefox
event.returnValue = false;
}
};
// Override mouse slide
document.body.addEventListener('wheel', (e) => {
if (e.ctrlKey) {
if (e.deltaY < 0) {
e.preventDefault();
return false;
}
if (e.deltaY > 0) {
e.preventDefault();
return false;
}
}
}, {
passive: false });
}
Do not right-click the browser
window.addEventListener('contextmenu', (e) => {
e.preventDefault();
})
- You need to see how to customize the right button , You can check out my article : How to customize the right button
边栏推荐
- redis 分布式锁整理
- 剑指 Offer II 010. 和为 k 的子数组 前缀和差
- 批量--07---断点重提
- Kalman filter meets deep learning: papers on Kalman filter and deep learning
- SMART PLC如何构造ALT指令
- [Jianzhi offer II 091. painting the house]
- Uniapp to preview pictures (single / multiple)
- Old mobile phones turn waste into treasure and serve as servers
- Singleton mode application
- Optimization of lazyagg query rewriting in parsing data warehouse
猜你喜欢

Creating a uniapp project using hbuilder x

PLSQL 存储函数SQL编程

Create a new ar fashion experience with cheese and sugar beans

Xshell connecting VMware virtual machines

Design and arrangement of DDIA data intensive application system

Old mobile phones turn waste into treasure and serve as servers

数学建模——线性规划

tensorflow 旧版本

vscode插件自用

Kotlin
随机推荐
微信公众号服务器配置
Redis系列——概述day1-1
Effects and laws
3年,我是如何涨薪到20k?
N皇后问题
Sword finger offer 50 First character that appears only once
FreeRTOS内核时钟不对的问题解决
【剑指 Offer II 091. 粉刷房子】
Home office earned me C | community essay
[black apple] Lenovo Savior y70002019pg0
内卷?泡沫?变革?十个问题直击“元宇宙”核心困惑丨《问Ta-王雷元宇宙时间》精华实录...
Sword finger offer II 014 A sliding window of anagrams in strings
上线移动ERP系统有哪些步骤?环环紧扣很重要
Tensorflow old version
Kalman Filter 遇到 Deep Learning : 卡尔曼滤波和深度学习有关的论文
3. conditional probability and independence
数学建模——线性规划
Redis系列——概述day1-1
How to talk about salary correctly in software testing interview
Next. JS hot update markdown file change