代碼如下:
<!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
<span onclick='parent.location.href="http://www.zol.com.cn"'>
中關村在線</span>
</div>
<div
<span >
電腦愛好者</span>
</div>
<div
>
<span >
新浪網</span>
</div>
<div
<span >
新華網</span>
</div>
</div>
</body>
</html>