<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>