javascript實現禁止右鍵和F12檢視原始碼
阿新 • • 發佈:2019-01-24
function click(e) {
if (document.all) {
if (event.button==2||event.button==3) { alert("歡迎光臨寒舍,有什麼需要幫忙的話,請與站長聯絡!謝謝您的合作!!!");
oncontextmenu='return false';
}
}
if (document.layers) {
if (e.which == 3) {
oncontextmenu='return false';
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;")
if (document.all) {
if (event.button==2||event.button==3) { alert("歡迎光臨寒舍,有什麼需要幫忙的話,請與站長聯絡!謝謝您的合作!!!");
oncontextmenu='return false';
}
}
if (document.layers) {
if (e.which == 3) {
oncontextmenu='return false';
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;")
document.onkeydown =document.onkeyup = document.onkeypress=function(){
if(window.event.keyCode == 123) {
window.event.returnValue=false;
return(false);
}
}
<--123——112是F1-F12的程式碼數-->