当前位置:网站首页>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 !
边栏推荐
- Android interview classic, 2022 Android interview written examination summary
- Leetcode: binary tree 15 (find the value in the lower left corner of the tree)
- Flume series: interceptor filtering data
- leetcode刷题:二叉树10(完全二叉树的节点个数)
- Debezium series: modify the source code to support drop foreign key if exists FK
- leetcode刷题:二叉树16(路径总和)
- Zhongang Mining: analysis of the current market supply situation of the global fluorite industry in 2022
- CADD课程学习(7)-- 模拟靶点和小分子相互作用 (半柔性对接 AutoDock)
- After 95, Alibaba P7 published the payroll: it's really fragrant to make up this
- Process file and directory names
猜你喜欢
港股将迎“最牛十元店“,名创优品能借IPO突围?
成功入职百度月薪35K,2022Android开发面试解答
leetcode刷题:二叉树10(完全二叉树的节点个数)
S7-200smart uses V90 Modbus communication control library to control the specific methods and steps of V90 servo
leetcode刷题:二叉树15(找树左下角的值)
建立自己的网站(16)
Database logic processing function
Redis cluster simulated message queue
[OBS] qstring's UTF-8 Chinese conversion to blog printing UTF-8 char*
[C language] string function and Simulation Implementation strlen & strcpy & strcat & StrCmp
随机推荐
leetcode刷题:二叉树15(找树左下角的值)
Leetcode brush questions: binary tree 11 (balanced binary tree)
The city chain technology Digital Innovation Strategy Summit was successfully held
Four methods of random number generation | random | math | threadlocalrandom | securityrandom
微信小程序正则表达式提取链接
leetcode刷题:二叉树12(二叉树的所有路径)
淺淺的談一下ThreadLocalInsecureRandom
线程池参数及合理设置
《乔布斯传》英文原著重点词汇笔记(十二)【 chapter ten & eleven】
力扣 729. 我的日程安排表 I
Zhongang Mining: analysis of the current market supply situation of the global fluorite industry in 2022
常用运算符与运算符优先级
处理文件和目录名
浅浅的谈一下ThreadLocalInsecureRandom
图嵌入Graph embedding学习笔记
Interviewer: what is the internal implementation of set data types in redis?
okcc呼叫中心有什么作用
Summer Challenge harmonyos - realize message notification function
Is it safe to open a mobile stock account? Is it reliable?
C application interface development foundation - form control (5) - grouping control