自定义浏览器右击菜单

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>show menu</title>
</head>
<style type="text/css">
*{
margin:0px;
padding:0px;
}
ul{
text-decoration:none;
font-family:Verdana, Geneva, sans-serif;
font-size:12px;
list-style:none;
}
ul li{
width:100%;
height:25px;
line-height:25px;
margin:0px;
text-align:center;
}
ul li a{
display:block;
border-left:10px #f7d solid;
background:#CCC;
color:#333;
padding:3px;
text-decoration:none;
}
ul li a:hover{
background:#3cf;
color:#fff;
}
</style>

<script>
function showyj()
{
if(event.button==2)
{
var yj = document.getElementById("yj");
var yj2 = document.getElementById("yj2");
yj.style.display="block";
yj2.style.display="block";
if(event.clientX>1120||event.clientY>670)
{
yj.style.display="none";
yj2.style.display="none";
return;
}
yj.style.pixelLeft= event.clientX;
yj.style.pixelTop = event.clientY;
yj2.style.pixelLeft=event.clientX;
yj2.style.pixelTop =event.clientY;
}
else
{
return;
}
}
function closediv()
{
yj.style.display="none";
yj2.style.display="none";
}
//-------------------------//

/*菜单功能模块*/
function reflash()
{
window.location.reload();
}
function changerbg()
{
document.bgColor="#ccffcc";
}
function alertme()
{
alert("hello world"+document.URL);
}
function closewindow()
{
window.opener=null;
window.close();
}
function  changerchar()
{
var sObj = document.getElementsByTagName("span");
sObj[0].style.color="red";
}
function nosrcoll()
{
b1.scroll = "no"
}
//------------------------//
document.onmousedown = showyj;
document.onclick = closediv;
</script>
<body id="b1"  oncontextmenu="return false" >
<div id="yj" style="position:absolute; width:130px; height:180px; display:none; background:#999; z-index:1">
<ul>
     <li><a href="#" onClick="nosrcoll()">关掉滚动</a></li>
     <li><a href="#" onClick="changerchar()">字体变色</a></li>
     <li><a href="#" onClick="reflash()">刷新页面</a></li>
     <li><a href="#" onClick="changerbg()">背景变色</a></li>
     <li><a href="#" onClick="alertme()">弹出提示</a></li>
     <li><a href="#" onClick="closewindow()">退出系统</a></li>
  </ul>
</div>

<div id="yj2" style="position:absolute; width:133px; height:201px; display:none; background:#999; filter:alpha(opacity=30)">
</div>
<span style=" font-size:18px; position:absolute; top:300px; left:400px;">用鼠标点右键,会弹出与众不同的菜单来</span>
<p style="position:absolute; left:2; top=2; font:Verdana, Geneva, sans-serif; color:#F00"> 

</p> 
</body>
</html>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值