<title>右键菜单v1.0</title>
<style>
body { font-family:Verdana;font-size:11px;background-color:#D6D3CE;}
#menu { position:absolute;border: 2px outset threedhighlight;background-color:inactiveborder;padding:2px;width:180px;visibility:hidden;}
.item { padding:2px;width:100%;cursor:default;border:1px solid inactiveborder;}
.item img { vertical-align:middle;margin-right:10px;}
.item span { visibility:hidden;width:21px;height:12px;}
.line { border-top:1px solid #848284;border-bottom:1px solid white;margin:2px;}
</style>
<body>
<SCRIPT LANGUAGE="JavaScript">
document.oncontextmenu = function() {showMenu();return false;}
document.onmouseup = function() {hiddenMenu();}
document.onselectstart = function() {return false;}
//system variable
var menuOpened = false;
//user variable
var oWhere = document.body;
var menu = document.createElement("div");
addItem("http://www.sayee.com/cloudchen/js/rightmenuimg/forward.gif","下一页","history.forward()",1);
addItem("http://www.sayee.com/cloudchen/js/rightmenuimg/back.gif","上一页","history.back()",1);
addItem("","刷新","history.go(0)",1);
addItem("","查看源文件","location.href='view-source:'+location.href",1);
addLine()
addItem("","我的主页","window.open('http://piggydesign.yeah.net')",1);
addItem("","我的网页日历","window.open('http://www.sayee.com/cloudchen/js/myCalendar.htm')",1);
addItem("","模拟列表框","window.open('http://www.sayee.com/cloudchen/js/simulation_select.htm')",1);
addLine()
addItem("","打印","window.print()",1);
addItem("","打印预览","document.all.WebBrowser.ExecWB(7,2)",1);
addLine()
addItem("","属性","document.all.WebBrowser.ExecWB(10,2)",1);
oWhere.appendChild(menu);
menu.id="menu";
menu.onmouseup = function() {event.cancelBubble=true;}
//addItem
function addItem(img,text,href,type) {
var item = document.createElement("div");
menu.appendChild(item);
if(img){item.innerHTML = "<img src="+img+">"}else{item.innerHTML = "<span></span>"};
if(text)item.innerHTML += text;
if(href)item.onmouseup = function() { clickGo(href,type)}
item.onmouseover = function() { mouseoverState(this)}
item.onmouseout = function() { mouseoutState(this)}
item.className="item";
}
function mouseoverState(obj) {
with(obj.style) {
border="1px solid #08246B";
backgroundColor="#9496AD"
}
}
function mouseoutState(obj) {
with(obj.style) {
border="1px solid inactiveborder";
backgroundColor="";
}
}
function clickGo(href,type) {
hiddenMenu();
switch(type) {
case 0:location.href=href;break;
case 1:javascript:eval(href);break;
}
}
//addLine
function addLine() {
line = document.createElement("div")
line.className = "line";
menu.appendChild(line);
}function showMenu() {
if(menuOpened) return false;
menuOpened = true;
var menu = document.all.menu;
with(menu.style) {
visibility="visible";
if(event.clientX+menu.offsetWidth>document.body.offsetWidth)
pixelLeft=event.clientX-menu.offsetWidth;
else
pixelLeft=event.clientX;
if(event.clientY+menu.offsetHeight>document.body.offsetHeight)
pixelTop=event.clientY-menu.offsetHeight;
else
pixelTop=event.clientY;
}
}
function hiddenMenu() {
if(!menuOpened) return false;
menuOpened = false;
var menu = document.all.menu;
with(menu.style) {
visibility="hidden";
}
}
</SCRIPT>
<object classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" id="WebBrowser" width="0" height="0">
</object>
自定义右键菜单v.10
<UL>
<LI>功能简单,使用方便
<LI>支持图片、链接、javascript函数
<LI>界面摹仿Acrobat Reader6.0
<LI>功能陆续完善中。。。
<LI>作者:cloudchen
<LI>创建日期:2003/8/25
</UL>
<style>
body { font-family:Verdana;font-size:11px;background-color:#D6D3CE;}
#menu { position:absolute;border: 2px outset threedhighlight;background-color:inactiveborder;padding:2px;width:180px;visibility:hidden;}
.item { padding:2px;width:100%;cursor:default;border:1px solid inactiveborder;}
.item img { vertical-align:middle;margin-right:10px;}
.item span { visibility:hidden;width:21px;height:12px;}
.line { border-top:1px solid #848284;border-bottom:1px solid white;margin:2px;}
</style>
<body>
<SCRIPT LANGUAGE="JavaScript">
document.oncontextmenu = function() {showMenu();return false;}
document.onmouseup = function() {hiddenMenu();}
document.onselectstart = function() {return false;}
//system variable
var menuOpened = false;
//user variable
var oWhere = document.body;
var menu = document.createElement("div");
addItem("http://www.sayee.com/cloudchen/js/rightmenuimg/forward.gif","下一页","history.forward()",1);
addItem("http://www.sayee.com/cloudchen/js/rightmenuimg/back.gif","上一页","history.back()",1);
addItem("","刷新","history.go(0)",1);
addItem("","查看源文件","location.href='view-source:'+location.href",1);
addLine()
addItem("","我的主页","window.open('http://piggydesign.yeah.net')",1);
addItem("","我的网页日历","window.open('http://www.sayee.com/cloudchen/js/myCalendar.htm')",1);
addItem("","模拟列表框","window.open('http://www.sayee.com/cloudchen/js/simulation_select.htm')",1);
addLine()
addItem("","打印","window.print()",1);
addItem("","打印预览","document.all.WebBrowser.ExecWB(7,2)",1);
addLine()
addItem("","属性","document.all.WebBrowser.ExecWB(10,2)",1);
oWhere.appendChild(menu);
menu.id="menu";
menu.onmouseup = function() {event.cancelBubble=true;}
//addItem
function addItem(img,text,href,type) {
var item = document.createElement("div");
menu.appendChild(item);
if(img){item.innerHTML = "<img src="+img+">"}else{item.innerHTML = "<span></span>"};
if(text)item.innerHTML += text;
if(href)item.onmouseup = function() { clickGo(href,type)}
item.onmouseover = function() { mouseoverState(this)}
item.onmouseout = function() { mouseoutState(this)}
item.className="item";
}
function mouseoverState(obj) {
with(obj.style) {
border="1px solid #08246B";
backgroundColor="#9496AD"
}
}
function mouseoutState(obj) {
with(obj.style) {
border="1px solid inactiveborder";
backgroundColor="";
}
}
function clickGo(href,type) {
hiddenMenu();
switch(type) {
case 0:location.href=href;break;
case 1:javascript:eval(href);break;
}
}
//addLine
function addLine() {
line = document.createElement("div")
line.className = "line";
menu.appendChild(line);
}function showMenu() {
if(menuOpened) return false;
menuOpened = true;
var menu = document.all.menu;
with(menu.style) {
visibility="visible";
if(event.clientX+menu.offsetWidth>document.body.offsetWidth)
pixelLeft=event.clientX-menu.offsetWidth;
else
pixelLeft=event.clientX;
if(event.clientY+menu.offsetHeight>document.body.offsetHeight)
pixelTop=event.clientY-menu.offsetHeight;
else
pixelTop=event.clientY;
}
}
function hiddenMenu() {
if(!menuOpened) return false;
menuOpened = false;
var menu = document.all.menu;
with(menu.style) {
visibility="hidden";
}
}
</SCRIPT>
<object classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" id="WebBrowser" width="0" height="0">
</object>
自定义右键菜单v.10
<UL>
<LI>功能简单,使用方便
<LI>支持图片、链接、javascript函数
<LI>界面摹仿Acrobat Reader6.0
<LI>功能陆续完善中。。。
<LI>作者:cloudchen
<LI>创建日期:2003/8/25
</UL>