当前位置:网站首页>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 !
边栏推荐
- 深度學習 卷積神經網絡(CNN)基礎
- Four methods of random number generation | random | math | threadlocalrandom | securityrandom
- 【obs】QString的UTF-8中文转换到blog打印 UTF-8 char*
- leetcode刷题:二叉树18(最大二叉树)
- Elk distributed log analysis system deployment (Huawei cloud)
- 95后阿里P7晒出工资单:狠补了这个,真香...
- 浅浅的谈一下ThreadLocalInsecureRandom
- 深度学习 卷积神经网络(CNN)基础
- MySql的root密码忘记该怎么找回
- Multi branch structure
猜你喜欢
.Net分布式事务及落地解决方案
成功入职百度月薪35K,2022Android开发面试解答
leetcode刷题:二叉树16(路径总和)
Android interview classic, 2022 Android interview written examination summary
618 "low key" curtain call, how can baiqiushangmei join hands with the brand to cross the "uncertain era"?
Recommended collection, my Tencent Android interview experience sharing
S7-200smart uses V90 Modbus communication control library to control the specific methods and steps of V90 servo
深度学习 卷积神经网络(CNN)基础
How about testing outsourcing companies?
Do you know several assertion methods commonly used by JMeter?
随机推荐
Two pits exported using easyexcel template (map empty data columns are disordered and nested objects are not supported)
webuploader文件上传 拖拽上传 进度监听 类型控制 上传结果监听控件
No matter how busy you are, you can't forget safety
挖财钱堂教育靠谱安全吗?
字节跳动Dev Better技术沙龙成功举办,携手华泰分享Web研发效能提升经验
[C language] string function and Simulation Implementation strlen & strcpy & strcat & StrCmp
随机数生成的四种方法|Random|Math|ThreadLocalRandom|SecurityRandom
leetcode刷题:二叉树15(找树左下角的值)
leetcode刷题:二叉树18(最大二叉树)
Ffplay document [easy to understand]
【obs】libobs-winrt :CreateDispatcherQueueController
Concept and syntax of function
JVMRandom不可设置种子|问题追溯|源码追溯
C language OJ gets PE, OJ of ACM introduction~
Interviewer: what is the internal implementation of set data types in redis?
Jvmrandom cannot set seeds | problem tracing | source code tracing
常用运算符与运算符优先级
Wildcard selector
Do you know several assertion methods commonly used by JMeter?
BZOJ 3747 POI2015 Kinoman 段树