<div class="codetitle"> <span><a style="CURSOR: pointer" data="15934" class="copybut" id="copybut15934" onclick="doCopy('code15934')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code15934"> <br><script language="javascript"> <BR>/document. oncontextmenu=Youji;*/ //為目前文件新增滑鼠右鍵事件,防止預設的右鍵選單彈出<BR>function Youji() <BR>{ <BR>alert("右鍵成功!"); <BR>return false; <BR>} <BR>//為某個dom元素新增滑鼠右鍵事件<BR>window.onload = function(){ <BR>document.getElementById("div1").oncontextmenu=Youji; <BR>} <BR></script> <br><div id="div1"> <br> </div> <br> </div>