当前位置:网站首页>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 !
边栏推荐
- Go language learning tutorial (XV)
- How to apply smart contracts more wisely in 2022?
- Is it safe for CICC fortune to open an account online?
- 零道云新UI设计中
- .Net分布式事务及落地解决方案
- 城链科技数字化创新战略峰会圆满召开
- C#应用程序界面开发基础——窗体控制(5)——分组类控件
- Complete interview questions for interviewers and senior Android engineers in front-line Internet enterprises
- Debezium series: idea integrates lexical and grammatical analysis ANTLR, and check the DDL, DML and other statements supported by debezium
- 【obs】QString的UTF-8中文转换到blog打印 UTF-8 char*
猜你喜欢
Elk distributed log analysis system deployment (Huawei cloud)
618 "low key" curtain call, how can baiqiushangmei join hands with the brand to cross the "uncertain era"?
[hard core dry goods] which company is better in data analysis? Choose pandas or SQL
40000 word Wenshuo operator new & operator delete
[OBS] qstring's UTF-8 Chinese conversion to blog printing UTF-8 char*
C application interface development foundation - form control (5) - grouping control
CADD课程学习(7)-- 模拟靶点和小分子相互作用 (半柔性对接 AutoDock)
[FAQ] summary of common causes and solutions of Huawei account service error 907135701
leetcode刷题:二叉树13(相同的树)
Parler de threadlocal insecurerandom
随机推荐
Debezium series: record the messages parsed by debezium and the solutions after the MariaDB database deletes multiple temporary tables
《乔布斯传》英文原著重点词汇笔记(十二)【 chapter ten & eleven】
Debezium series: idea integrates lexical and grammatical analysis ANTLR, and check the DDL, DML and other statements supported by debezium
sun.misc.BASE64Encoder报错解决方法[通俗易懂]
leetcode刷题:二叉树10(完全二叉树的节点个数)
零道云新UI设计中
Cocos2d-x项目总结中的一些遇到的问题
95后阿里P7晒出工资单:狠补了这个,真香...
Process file and directory names
SecureRandom那些事|真伪随机数
Ffplay document [easy to understand]
Summer Challenge harmonyos - realize message notification function
Debezium series: PostgreSQL loads the correct last submission LSN from the offset
多分支结构
Go language learning tutorial (XV)
The city chain technology Digital Innovation Strategy Summit was successfully held
Multi branch structure
leetcode刷题:二叉树16(路径总和)
[C language] string function and Simulation Implementation strlen & strcpy & strcat & StrCmp
leetcode刷题:二叉树11(平衡二叉树)