<img src="images/xd.gif" onclick="javascript:if(event.button==2) zuojian();">event.button [ = iWhichButton ]
Possible ValuesiWhichButton Integer that specifies or receives one of the following values.0 Default. No button is pressed.
1 Left button is pressed.
2 Right button is pressed.
3 Left and right buttons are both pressed.
4 Middle button is pressed.
5 Left and middle buttons both are pressed.
6 Right and middle buttons are both pressed.
7 All three buttons are pressed.
Possible ValuesiWhichButton Integer that specifies or receives one of the following values.0 Default. No button is pressed.
1 Left button is pressed.
2 Right button is pressed.
3 Left and right buttons are both pressed.
4 Middle button is pressed.
5 Left and middle buttons both are pressed.
6 Right and middle buttons are both pressed.
7 All three buttons are pressed.
onclick 怎么也接收不到右键事件
TO 楼主, 这个右键事件已经明确地只加在了图片上, 不会影响其它元素的系统右键菜单的.
oncontextmenu="return mm()">
<SCRIPT LANGUAGE="JavaScript">
function mm()
{
alert('自定义');
return false;
}
</SCRIPT>
<SCRIPT language="javascript">
<!--
function showmenuie5(){
var rightedge=document.body.clientWidth-event.clientX
var bottomedge=document.body.clientHeight-event.clientY
if (rightedge<ie5menu.offsetWidth)
ie5menu.style.left=document.body.scrollLeft+event.clientX-ie5menu.offsetWidth
else
ie5menu.style.left=document.body.scrollLeft+event.clientX
if (bottomedge<ie5menu.offsetHeight)
ie5menu.style.top=document.body.scrollTop+event.clientY-ie5menu.offsetHeight
else
ie5menu.style.top=document.body.scrollTop+event.clientY
ie5menu.style.visibility="visible"
return false
}function hidemenuie5(){
ie5menu.style.visibility="hidden"
}function highlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor="highlight"
event.srcElement.style.color="white"
}
}
function lowlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="black"
}
}
function jumptoie5()
{
if (event.srcElement.className=="menuitems")
{
if (event.srcElement.url != '')
{
if (event.srcElement.getAttribute("target")!=null)
window.open(event.srcElement.url,event.srcElement.getAttribute("target"))
else
window.location=event.srcElement.url
}
}
}
//-->
</SCRIPT><STYLE type=text/css>
.cMenu {
BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; FONT-WEIGHT: normal; FONT-SIZE: 14px; VISIBILITY: hidden; BORDER-LEFT: #000000 1px solid; WIDTH: 100px; CURSOR: default; COLOR: #000000; LINE-HEIGHT: 20px; BORDER-BOTTOM: #000000 1px solid; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; POSITION: absolute; BACKGROUND-COLOR: #eeeeff
}
.menuitems {
PADDING-RIGHT: 5px; PADDING-LEFT: 5px
}
</STYLE>
</HEAD>
<BODY>
你按右键试一试<!-- <RIGHTCLICK> -->
<!--[if IE]>
<DIV class=cMenu id=ie5menu onmouseover=highlightie5() onclick=jumptoie5() onmouseout=lowlightie5()>
<DIV class=menuitems target="_blank" url="http://www.dev-clun.com">开发者俱乐部</DIV>
<DIV class=menuitems target="_blank" url="http://www.sohu.com">搜狐网</DIV>
<DIV class=menuitems target="_blank" url="http://www.yesky.com">天极网</DIV>
<DIV class=menuitems target="_blank" url="http://www.163.com">网易</DIV>
<DIV class=menuitems target="_blank" url="http://www.sina.com.cn">新浪网</DIV>
<DIV class=menuitems target="_blank" url="http://www.yahoo.com">雅虎网</DIV>
<DIV class=menuitems target="_blank" url="http://www.tom.com">tom</DIV>
</DIV>
<![endif]-->
<SCRIPT language=JavaScript>
<!--
function youjian(zhi)
{
if (event.button==2||event.button==3)
//if (document.all&&window.print)
//if (document.all){
alert("先试右键");
ie5menu.className="cMenu";
document.oncontextmenu=showmenuie5;
document.body.onclick=hidemenuie5;
}
else
{
alert("先试d右键");//document.oncontextmenu="";
}}
//-->
</SCRIPT>
<!-- </RIGHTCLICK> -->
<!-- <img src="images/xd.gif" oncontextmenu="youjian(1);return false;" > -->
哈哈d
<img src="images/logo.gif" onMouseDown="youjian(1);">
</BODY></HTML>
{
if (event.button==2||event.button==3)
//if (document.all&&window.print)
//if (document.all){
alert("先试右键");
ie5menu.className="cMenu";
document.oncontextmenu=showmenuie5; //在这里已经重载了网页的右键事件
document.body.onclick=hidemenuie5;
}
再也无法回到以前默认的windows 的默认的东西了?
{
return true;
}
document.oncontextmenu="return true;";
放哪里都没有达到效果。