function click(e) { if (document.all) { if (event.button==1||event.button==2||event.button==3) { 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;") var trxdyel=true var hotkey=17 /* hotkey即爲熱鍵的鍵值,是ASII碼,這裏99表明c鍵 */ if (document.layers) document.captureEvents(Event.KEYDOWN) function gogo(e) { if (document.layers) { if (e.which==hotkey && trxdyel) { alert('操做錯誤.或許是您按錯鍵了!'); } } else if (document.all) { if (event.keyCode==hotkey&&trxdyel){ alert('操做錯誤.或許是您按錯鍵了!'); }} } document.onkeydown=gogo
將以上JS代碼寫到JS文件中取名爲xp.js並放入Script文件夾中,引用時須要注意設置Charset=「gb2312」,否則提示出的信息會是亂碼。頁面引用: javascript
<script src="../Script/xp.js" type="text/javascript" charset="gb2312"></script>
1. 將完全屏蔽鼠標右鍵