document.addEventListener或者jquery $('body').on('mousedown','div',function(e){
if( e.button == 2 ) {
alert($(this).html());
return false;
}
return true;
});
if( e.button == 2 ) {
alert($(this).html());
return false;
}
return true;
});
解决方案 »
- 怎样动态设置表单里button属性
- 紧急求助swfobject问题
- 只用javascript 脚本就能生成校验码图吗?
- 服务端分段输入, ajax能否分段接收?
- 如何取得按钮位置
- 双击一个textbox,跳转到另一个页面,怎么做?
- 我用window.open打开一个框架,请问怎样将框架中的一个页面中的值传到他的前一个页面中
- 高手指教了~
- 我用window.showModalDialog打开子窗口,为什么子窗口的iframe变成不了只读?
- window.orientation犯神经病了!
- window.clipboardData.getData('Text')问题
- extjs3 tree问题,求助
<script type="text/javascript">
$(function(){
$('.menu').contextmenu(function(e){
if ( e && e.preventDefault ){
e.preventDefault();
} else {
window.event.returnValue = false;
};
alert($(this).html());
});
});
</script>
<div class="menu">1</div><div class="menu">2</div>
e=e||envent;
var obj = e.srcElement ||e.target;};
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
window.onload=function(){
var divs=document.getElementsByTagName("div");
for(var i=0,len=divs.length;i<len;i++){
divs[i].oncontextmenu=function(e){
var a=e||window.event;
if(a.preventDefault){
a.preventDefault();
}else{
a.returnValue=false;
}
alert(this.innerHTML);
}
}
}
</script>
</head><body>
<div>1</div>
<div>2</div>
<div>3</div>
</body>
</html>
document.oncontextmenu = function(e){
e = e || event;
var tag = e.target || e.srcElement;
alert(tag.innerHTML);
return false;
}
</script>