勤劳一日,可得一夜安眠;勤劳一生,可得幸福长眠。——达·芬奇

js禁止右键点击事件触发代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function click() {
return false;
}

function click1() {
if (event.button == 2) {
return false;
}
}

function CtrlKeyDown() {
if (event.ctrlKey) {
return false;
}
}
document.onkeydown = CtrlKeyDown;
document.onselectstart = click;
document.onmousedown = click1;
document.oncontextmenu = function(event) {
if (document.all)
window.event.returnValue = false; // for IE
else
event.preventDefault();
}