這樣之后,點擊右鍵,不會觸發(fā)事件,自帶的事件選框也沒有了~
鼠標左右鍵都可以觸發(fā)click,mousedown等事件,可以通過event.which使得鼠標右鍵不出發(fā)事件,但是鼠標右鍵自帶的下面的選項是可以被觸發(fā)的,所以需要把下面默認的選項框也隱藏掉
event.which 屬性返回指定事件上哪個鍵盤鍵或鼠標按鈕被按下;
這樣之后,點擊右鍵,不會觸發(fā)事件,自帶的事件選框也沒有了~
<script type="text/javascript">
function iEsc() { return false; }
function iRec() { return true; }
function DisableKeys() {
if (event.ctrlKey || event.shiftKey || event.altKey) {
window.event.returnValue = false;
iEsc();
}
}
function DisableRightClick(www_qsyz_net) {
if (window.Event) {
if (www_qsyz_net.which == 2 || www_qsyz_net.which == 3)
iEsc();
}
else if (event.button == 2 || event.button == 3) {
event.cancelBubble = true
event.returnValue = false;
iEsc();
}
}
document.ondragstart = iEsc;
document.onkeydown = DisableKeys;
document.oncontextmenu = iEsc;
if (typeof document.onselectstart != "undefined")
document.onselectstart = iEsc;
else {
document.onmousedown = iEsc;
document.onmouseup = iRec;
}
</script>
<style type="text/css">
body {
-moz-user-select: none;
-webkit-user-select: none;
}
</style>
相關(guān)推薦