当前位置:网站首页>JS implementation prohibits web page zooming (ctrl+ mouse, +, - zooming effective pro test)
JS implementation prohibits web page zooming (ctrl+ mouse, +, - zooming effective pro test)
2022-07-05 20:03:00 【Dehong demon king】

background : It's early morning 1:35 I'm still helping clients modify their web pages , Not demanding but quick money , The student party is not easy , The customer mentioned many web page optimization , This one
It gives me a headache for a long time , You don't have to step on the pit , Just look at the one below
Prohibit pulley :
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});
prohibit +、- :
window.onload = function() {
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);
}
Complete code :
<script>
//luwenjie hualun
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});
//+_
window.onload = function() {
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);
}
</script>
Just look at the outline , Anyway, neither of them will zoom , That's it today !
边栏推荐
- ACM getting started Day1
- Inventory of the most complete low code / no code platforms in the whole network: Jiandao cloud, partner cloud, Mingdao cloud, Qingliu, xurong cloud, Jijian cloud, treelab, nailing · Yida, Tencent clo
- Thread pool parameters and reasonable settings
- Process file and directory names
- .Net分布式事务及落地解决方案
- 深度学习 卷积神经网络(CNN)基础
- Leetcode: binary tree 15 (find the value in the lower left corner of the tree)
- Debezium series: parsing the default value character set
- What is PyC file
- Is the education of caiqiantang reliable and safe?
猜你喜欢

深度學習 卷積神經網絡(CNN)基礎
![[FAQ] summary of common causes and solutions of Huawei account service error 907135701](/img/1d/0e716533237c0e4463f5d6357395bd.png)
[FAQ] summary of common causes and solutions of Huawei account service error 907135701

城链科技数字化创新战略峰会圆满召开

【无标题】

webuploader文件上传 拖拽上传 进度监听 类型控制 上传结果监听控件

leetcode刷题:二叉树14(左叶子之和)

Interviewer: what is the internal implementation of set data types in redis?

third-party dynamic library (libcudnn.so) that Paddle depends on is not configured correctl

Redis cluster simulated message queue
Android interview classic, 2022 Android interview written examination summary
随机推荐
How to retrieve the root password of MySQL if you forget it
Go language | 02 for loop and the use of common functions
建立自己的网站(16)
How to select the Block Editor? Impression notes verse, notation, flowus
处理文件和目录名
third-party dynamic library (libcudnn.so) that Paddle depends on is not configured correctl
手机股票开户安全吗?靠不靠谱啊?
Thread pool parameters and reasonable settings
Bitcoinwin (BCW) was invited to attend Hanoi traders fair 2022
Go language | 03 array, pointer, slice usage
Successful entry into Baidu, 35K monthly salary, 2022 Android development interview answer
The difference between ID selector and class selector
selenium 元素信息
Process file and directory names
Android interview classic, 2022 Android interview written examination summary
gst-launch的-v参数
Debezium series: PostgreSQL loads the correct last submission LSN from the offset
c語言oj得pe,ACM入門之OJ~
浅浅的谈一下ThreadLocalInsecureRandom
[untitled]