不是說我試圖阻止「查看源代碼」或任何愚蠢的東西,但我爲某些元素做了一些自定義上下文菜單。如何禁用JavaScript中的右鍵單擊上下文菜單
編輯:迴應的答案:我已經試過這樣:
<a id="moo" href=''> </a>
<script type="text/javascript">
var moo = document.getElementById('moo');
function handler(event) {
event = event || window.event;
if (event.stopPropagation)
event.stopPropagation();
event.cancelBubble = true;
return false;
}
moo.innerHTML = 'right-click here';
moo.onclick = handler;
moo.onmousedown = handler;
moo.onmouseup = handler;
</script>
右鍵點擊被禁用,但是,按住Ctrl鍵的點擊仍然在Firefox中處於活動狀態。請禁用按住Ctrl鍵或在Firefox中右鍵點擊。 – 2017-10-09 07:04:37