下面就是實(shí)現(xiàn)效果所需代碼:
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 travel=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&&travel){
alert("操作錯(cuò)誤.或許是您按錯(cuò)了按鍵!"); } }
else if (document.all){
if (event.keyCode==hotkey&&travel){ alert("操作錯(cuò)誤.或許是您按錯(cuò)了按鍵!"); }}
}
document.onkeydown=gogo
把上面的代碼另存為一個(gè)JS文件,然后在想實(shí)現(xiàn)此效果的頁面調(diào)用即可!
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。