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

王朝html/css/js·作者佚名  2008-05-30
窄屏简体版  字體: |||超大  

代码如下:

<!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>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航