右键弹出自定义菜单,很有意思呀!

发表于:2007-06-30来源:作者:点击数: 标签:
HTMLHEADTITLE右键菜单/TITLE SCRIPT language= java script !-- function showmenuie5(){ var rightedge=document.body.clientWidth-event.clientX var bottomedge=document.body.clientHeight-event.clientY if (rightedgeie5menu.offsetWidth) ie5menu.sty
<HTML><HEAD><TITLE>右键菜单</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: 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>
<!--
if (document.all&&window.print){
ie5menu.className="cMenu"
document.oncontextmenu=showmenuie5
document.body.onclick=hidemenuie5
}
//-->
</SCRIPT>
</RIGHTCLICK>
</BODY></HTML> 

原文转自:http://www.ltesting.net