FreeSpread

知而获智,智达高远
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

js - 用Popup对象构建网页右键菜单

Posted on 2006-08-06 16:15  FreeSpread  阅读(411)  评论(0)    收藏  举报
   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<TITLE>Popup对象实现右键菜单</TITLE>
<script language="JavaScript">
var oPopup = window.createPopup();
function contextMenu()
{
   
    var left = event.offsetX+10;
    var top = event.offsetY+10;
    oPopup.document.body.innerHTML = oContext.innerHTML;
    oPopup.show(left, top, 120, 80, window.document.body);
   
}
</script>
</head>
<body oncontextmenu="contextMenu(); return false;">
<h1>Popup对象实现右键菜单</h1>
单击鼠标右键查看效果
<div ID="oContext" style="DISPLAY: none; BACKGROUND: #e4e4e4; ">
    <div onmouseover="this.style.background='gold'"
         onmouseout="this.style.background='#e4e4e4'"
       <span onclick='parent.location.href="http://www.ydbl.cn"'>
    运动部落</span>
    </div>
    <div onmouseover="this.style.background='gold'"
         onmouseout="this.style.background='#e4e4e4'"
    <span onclick="parent.location.href='http://fxjun.cnblogs.com'">
    FreeSpread博客</span>
    </div>
</div>
</body>
</html>