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

2008-02-23 08:02:15来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

代码如下:

<!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.webjx.com'">
网页教学网</span>
</div>

</div>
</body>
</html>

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:用Javascript实现评估用户输入密码的强度

下一篇:VBScript教程第一课 什么是 VBScript