下文不做具体解释了,知识做个随笔
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style type="text/css">
#div1 {width:200px; height:200px; background:red; position:absolute;display: none;}
</style>
<script>
document.oncontextmenu=function(ev){
var eve=ev||event;
var odiv=document.getElementById('div1');
odiv.style.left=eve.clientX+'px';
odiv.style.top=eve.clientY+'px';
odiv.style.display='block';
return false;
}
document.onclick=function(){
var odiv=document.getElementById('div1');
odiv.style.display='none';
}
</script>
</head>
<body>
<div id="div1">
</div>
</body>
</html>