当前位置:网站首页>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 !
边栏推荐
- leetcode刷题:二叉树18(最大二叉树)
- Force buckle 729 My schedule I
- Fundamentals of deep learning convolutional neural network (CNN)
- 期货如何网上开户?安不安全?
- 2023年深圳市绿色低碳产业扶持计划申报指南
- Complete interview questions for interviewers and senior Android engineers in front-line Internet enterprises
- BZOJ 3747 POI2015 Kinoman 段树
- Win10 x64环境下基于VS2017和cmake-gui配置使用zxing以及opencv,并实现data metrix码的简单检测
- S7-200smart uses V90 Modbus communication control library to control the specific methods and steps of V90 servo
- 成功入职百度月薪35K,2022Android开发面试解答
猜你喜欢

js实现禁止网页缩放(Ctrl+鼠标、+、-缩放有效亲测)
![[OBS] qstring's UTF-8 Chinese conversion to blog printing UTF-8 char*](/img/cc/172684664a9115943d45b0646ef110.png)
[OBS] qstring's UTF-8 Chinese conversion to blog printing UTF-8 char*

How to apply smart contracts more wisely in 2022?

【无标题】

2023年深圳市绿色低碳产业扶持计划申报指南

.Net分布式事务及落地解决方案

众昂矿业:2022年全球萤石行业市场供给现状分析

Autumn byte interviewer asked you any questions? In fact, you have stepped on thunder

力扣 729. 我的日程安排表 I

How to safely and quickly migrate from CentOS to openeuler
随机推荐
Go language learning tutorial (16)
leetcode刷题:二叉树18(最大二叉树)
ICTCLAS用的字Lucene4.9捆绑
【c语言】快速排序的三种实现以及优化细节
C - sequential structure
[C language] three implementations of quick sorting and optimization details
Using repositoryprovider to simplify the value passing of parent-child components
股票开户哪里好?网上客户经理开户安全吗
解决php无法将string转换为json的办法
Tasks in GStreamer
Go language | 02 for loop and the use of common functions
Zhongang Mining: analysis of the current market supply situation of the global fluorite industry in 2022
Debezium series: modify the source code to support drop foreign key if exists FK
Is it safe for Guosen Securities to open an account online?
S7-200smart uses V90 Modbus communication control library to control the specific methods and steps of V90 servo
成功入职百度月薪35K,2022Android开发面试解答
多分支结构
挖财钱堂教育靠谱安全吗?
MySql的root密码忘记该怎么找回
What is the core value of testing?