function rightbt(val) { var evt=getEvent(); var msgObj=document.getElementById("myMenudiv"); document.getElementById("contextMenu").innerHTML="<li class=/"edit/" onmouseover=/"this.style.background='#3399FF'/" onmouseout=/"this.style.background=''/"><a onclick=/"sendmail('"+val+"')/" >发邮件</a></li><li onmouseover=/"this.style.background='#3399FF'/" onmouseout=/"this.style.background=''/" class=/"cut separator/"><a onclick=/"sendmessage('"+val+"')/">发消息</a></li>"; var moveTop = parseInt(evt.clientY); var moveLeft = parseInt(evt.clientX); msgObj.style.display=""; msgObj.style.left=moveLeft+ "px"; msgObj.style.top=moveTop+ "px"; // evt.returnvalue=false }
oncontextmenu=/"rightbt('"+dObj[i].emailaddress+"')/" //次事件 是鼠标右键单击事件
document.oncontextmenu=function() { return false; } //屏蔽鼠标右键,ff ie 通过测试
<div id="myMenudiv" style=" position: absolute; width: 100px; height: 40px;"> <ul id="contextMenu" class="Menu"> </ul> </div>
/* Generic context menu styles */ .Menu { width: 100px; border: solid 1px #CCC; background: #EEE; padding: 0px; margin: 0px; } .Menu LI { list-style: none; padding: 0px; margin: 0px; } .Menu li A { color: #333; text-decoration: none; line-height: 20px; height: 20px; background-position: 6px center; background-repeat: no-repeat; outline: none; padding: 1px 5px; padding-left: 15px; cursor:pointer; } .Menu LI.separator { border-top: solid 1px #CCC; } /* Adding Icons You can add icons to the context menu by adding classes to the respective LI element(s) */ .Menu LI.edit A { background-image: url(images/page_white_edit.png); } .Menu LI.cut A { background-image: url(images/cut.png); } .Menu LI.copy A { background-image: url(images/page_white_copy.png); } .Menu LI.paste A { background-image: url(images/page_white_paste.png); } .Menu LI.delete A { background-image: url(images/page_white_delete.png); } .Menu LI.quit A { background-image: url(images/door.png); }