1// 屏蔽鼠标右键菜单
2document.oncontextmenu = function () {
3 return false;
4};
5
6document.addEventListener("contextmenu", e => e.preventDefault());
1<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <meta charset="UTF-8" />
5 <link rel="icon" href="/favicon.ico" />
6 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7 <title>Vite App</title>
8 </head>
9 <!-- 禁用鼠标右键菜单 -->
10 <body oncontextmenu="self.event.returnValue = false">
11 <div id="app"></div>
12 <script type="module" src="/src/main.js"></script>
13 </body>
14</html>
1window.onload = function () {
2 document.onkeydown = function () {
3 let e = window.event || arguments[0];
4 if (e.keyCode == 123) {
5 return false;
6 } else if (e.ctrlKey && e.shiftKey && e.keyCode == 73) {
7 return false;
8 } else if (e.ctrlKey && e.keyCode == 85) {
9 return false;
10 }
11 };
12 // 屏蔽鼠标右键菜单
13 document.oncontextmenu = function () {
14 return false;
15 };
16};