if (event.button == 1) {
  div层.style.display = "none";
}

解决方案 »

  1.   

    http://go6.163.com/ghztavon这个网站里有演示及代码。
      

  2.   

    这个你参考一下!javascript event 对象
    javascript1.2中引入event对象作为提供时间其他对象的机制。这个信息是通过
    event对象的属性提供的。
    一,下面介绍IE中event的属性。属性                  说明
    screenX和screenY      光标相对于屏幕的水平和垂直位置(像素)
    ClientX和ClientY      光标相对于事件所在的web页面的水平和垂直位置(像素)
    OffsetX和OffsetY      光标相对于事件所在的容器的水平和垂直位置(像素)
    x和Y                  光标相对于事件所在的文档的水平和垂直位置(像素)
    srcElement            最初发生时间的目标对象
    type                  发生的事件类型
    keycode               表识与所按键相关的unicode键代码
    button                发生事件时所安的鼠标键(0=无,1=左,2=右,4=中)
    altKey                设置为真或假,表示发生事件时是否按了Alt,Ctr,Shift
    crlKey
    shiftKey
    cancelbubble         设置为真为假,表示取消或启用事件气泡
    fromElement          指定移动的html元素
    toElement 
    reason              表示数据源对象的数据传输状态
    returnValue         表示事件处理器的的返回值
    srcFliter           指定产生onfilterchange事件的filter的对象
    二。简单应用举例
    下例党在浏览器的文档用鼠标右击时弹出一个对话框。灵活运用event对象可产生很多有趣的效果。   <html><head>
    <script language=javascript>
    function esckey(keycode)
    {         
              if(keycode==2)
                  {window.alert("你好")
                 }
    }
    </script>
    </head>
    <body  onmouseup="javascript:esckey(window.event.button)">
    </body>
    </html>
      

  3.   

    我想下面的代码你应该会满意的。把代码复制下来存成 .htm 的文件是一下吧,这可是很不错的右键菜单哦。^(oo)^<HTML><HEAD><TITLE>IE右键菜单</TITLE>
    <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: 150px; 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.lilacsoft.com">苦丁香公司网站首页</DIV>
    <DIV class=menuitems target="_blank" url="http://www.lilacsoft.com/news/kuaibao2.asp">苦丁香最新动态</DIV>
    <DIV class=menuitems target="_blank" url="http://www.lilacsoft.com/product/cai.htm">教育软件介绍</DIV>
    <DIV class=menuitems target="_blank" url="http://www.lilacsoft.com/product/demodown.htm">苦丁香演示版下载</DIV>
    <DIV class=menuitems target="_blank" url="http://www.lilacsoft.com/channel/shichangdiaoyan.asp">在线市场调研</DIV>
    <DIV class=menuitems target="_blank" url="http://www.lilacsoft.com/jiaoliu/message/Default.asp">苦丁香留言版</DIV>
    <DIV class=menuitems target="_blank" url="http://www.lilacsoft.com/about/zhaoping.htm">苦丁香新员工招聘</DIV>
    <DIV class=menuitems target="_blank" url="http://www.lilacsoft.com/about/jieshao.htm">关于苦丁香......</DIV>
    <HR color=#aaaaaa size="0">
    <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>
    <![endif]-->
    <SCRIPT language=JavaScript>
    <!--
    if (document.all&&window.print){
    ie5menu.className="cMenu"
    document.oncontextmenu=showmenuie5
    document.body.onclick=hidemenuie5
    }
    //-->
    </SCRIPT>
    </RIGHTCLICK> 
    </BODY></HTML>