<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title></title>
<style type="text/css">
#mymenu{
display:none;
position:absolute;
}
</style>
<script type="text/javascript">
//**.oncontextmenu 系统自定义的右键菜单这个W3里面没有.
function menu(e){
//alert(e.button);
//1.找到我们的菜单对象,并在当前鼠标坐标添加事件属性方法
if(e.button==2){
var mymenu=document.getElementById("mymenu");
mymenu.style.display="block";
//clientY 返回当事件被触发时,鼠标指针的垂直坐标.
mymenu.style.top=e.clientY + "px";
mymenu.style.left=e.clientx + "px";
return false;
}
}
</script>
</head>
<body>
<table border="1" oncontextmenu="return false;" onmousedown="menu(event)">
<tr>
<td>姓名</td>
<td>性别</td>
</tr>
<tr>
<td>admin</td>
<td>男</td>
</tr>
<tr>
<td>guest</td>
<td>男</td>
</tr>
</table>
<div id="mymenu">
<ul>
<li>删除</li>
<li>修改</li>
</ul>
</div>
</body>
</html>