代码如下:
<!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.zol.com.cn"'>
中关村在线</span>
</div>
<div onmouseover="this.style.background='gold'"
onmouseout="this.style.background='#e4e4e4'"
<span onclick="parent.location.href='http://www.cfan.com.cn'">
电脑爱好者</span>
</div>
<div onmouseover="this.style.background='gold';"
onmouseout="this.style.background='#e4e4e4';">
<span onclick="parent.location.href='http://www.sina.com.cn'">
新浪网</span>
</div>
<div onmouseover="this.style.background='gold'"
onmouseout="this.style.background='#e4e4e4'"
<span onclick="parent.location.href='http://www.xinhuanet.com'">
新华网</span>
</div>
</div>
</body>
</html>
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |