如何在 JavaScript 中禁用右键单击上下文菜单
2022-08-30 02:25:17
并不是说我试图阻止“查看源代码”或类似的东西,而是我正在为某些元素制作一些自定义上下文菜单。
编辑:对答案的回应:我试过这个:
<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>