分享
 
 
 

超酷的XP风格的网页右键菜单特效代码

王朝html/css/js·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

<HTML>

<HEAD>

<TITLE></TITLE>

<META content="text/html; charset=gb2312" http-equiv=Content-Type>

<META content="MSHTML 5.00.2920.0" name=GENERATOR>

<script>

<!--

// menu object

function contextMenu()

{

this.items = new Array();

this.addItem = function (item)

{

this.items[this.items.length] = item;

}

this.show = function (oDoc)

{

var strShow = "";

var i;

strShow = "<div id=\"rightmenu\" style=\"BACKGROUND-COLOR: #ffffff; BORDER: #000000 1px solid; LEFT: 0px; POSITION: absolute; TOP: 0px; VISIBILITY: hidden; Z-INDEX: 10\">";

strShow += "<table border=\"0\" height=\"";

strShow += this.items.length * 20;

strShow += "\" cellpadding=\"0\" cellspacing=\"0\">";

strShow += "<tr height=\"3\"><td bgcolor=\"#d0d0ce\" width=\"2\"></td><td>";

strShow += "<table border=\"0\" width=\"100%\" height=\"100%\" cellpadding=0 cellspacing=0 bgcolor=\"#ffffff\">";

strShow += "<tr><td bgcolor=\"#d0d0ce\" width=\"23\"></td><td><img src=\" \" height=\"1\" border=\"0\"></td></tr></table>";

strShow += "</td><td width=\"2\"></td></tr>";

strShow += "<tr><td bgcolor=\"#d0d0ce\"></td><td>";

strShow += "<table border=\"0\" width=\"100%\" height=\"100%\" cellpadding=3 cellspacing=0 bgcolor=\"#ffffff\">";

oDoc.write(strShow);

for(i=0; i<this.items.length; i++)

{

this.items[i].show(oDoc);

}

strShow = "</table></td><td></td></tr>";

strShow += "<tr height=\"3\"><td bgcolor=\"#d0d0ce\"></td><td>";

strShow += "<table border=\"0\" width=\"100%\" height=\"100%\" cellpadding=0 cellspacing=0 bgcolor=\"#ffffff\">";

strShow += "<tr><td bgcolor=\"#d0d0ce\" width=\"23\"></td><td><img src=\" \" height=\"1\" border=\"0\"></td></tr></table>";

strShow += "</td><td></td></tr>";

strShow += "</table></div>\n";

oDoc.write(strShow);

}

}

// menu Item object

function contextItem(text, icon, cmd, type)

{

this.text = text ? text : "";

this.icon = icon ? icon : "";

this.cmd = cmd ? cmd : "";

this.type = type ? type : "menu";

this.show = function (oDoc)

{

var strShow = "";

if(this.type == "menu")

{

strShow += "<tr ";

strShow += "onmouseover=\"changeStyle(this, 'on');\" ";

strShow += "onmouseout=\"changeStyle(this, 'out');\" ";

strShow += "onclick=\"";

strShow += this.cmd;

strShow += "\">";

strShow += "<td class=\"ltdexit\" width=\"16\">";

if (this.icon == "")

strShow += "&nbsp;";

else {

strShow += "<img border=\"0\" src=\"";

strShow += this.icon;

strShow += "\" width=\"16\" height=\"16\" style=\"POSITION: relative\"></img>";

}

strShow += "</td><td class=\"mtdexit\">";

strShow += this.text;

strShow += "</td><td class=\"rtdexit\" width=\"5\">&nbsp;</td></tr>";

}

else if (this.type == "separator")

{

strShow += "<tr><td class=\"ltdexit\">&nbsp;</td>";

strShow += "<td class=\"mtdexit\" colspan=\"2\"><hr color=\"#000000\" size=\"1\"></td></tr>";

}

oDoc.write(strShow);

}

}

function changeStyle(obj, cmd)

{

if(obj) try {

var imgObj = obj.children(0).children(0);

if(cmd == 'on') {

obj.children(0).className = "ltdfocus";

obj.children(1).className = "mtdfocus";

obj.children(2).className = "rtdfocus";

if(imgObj)

{

if(imgObj.tagName.toUpperCase() == "IMG")

{

imgObj.style.left = "-1px";

imgObj.style.top = "-1px";

}

}

}

else if(cmd == 'out') {

obj.children(0).className = "ltdexit";

obj.children(1).className = "mtdexit";

obj.children(2).className = "rtdexit";

if(imgObj)

{

if(imgObj.tagName.toUpperCase() == "IMG")

{

imgObj.style.left = "0px";

imgObj.style.top = "0px";

}

}

}

}

catch (e) {}

}

function showMenu()

{

var x, y, w, h, ox, oy;

x = event.clientX;

y = event.clientY;

var obj = document.getElementById("rightmenu");

if (obj == null)

return true;

ox = document.body.clientWidth;

oy = document.body.clientHeight;

if(x > ox || y > oy)

return false;

w = obj.offsetWidth;

h = obj.offsetHeight;

if((x + w) > ox)

x = x - w;

if((y + h) > oy)

y = y - h;

obj.style.posLeft = x + document.body.scrollLeft;

obj.style.posTop = y + document.body.scrollTop;

obj.style.visibility = "visible";

return false;

}

function hideMenu()

{

if(event.button == 0)

{

var obj = document.getElementById("rightmenu");

if (obj == null)

return true;

obj.style.visibility = "hidden";

obj.style.posLeft = 0;

obj.style.posTop = 0;

}

}

function writeStyle()

{

var strStyle = "";

strStyle += "<STYLE type=text/css>";

strStyle += "TABLE {Font-FAMILY: \"Tahoma\",\"Verdana\",\"宋体\"; FONT-SIZE: 9pt}";

strStyle += ".mtdfocus {BACKGROUND-COLOR: #ccccff; BORDER-BOTTOM: #000000 1px solid; BORDER-TOP: #000000 1px solid; CURSOR: hand}";

strStyle += ".mtdexit {BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid}";

strStyle += ".ltdfocus {BACKGROUND-COLOR: #ccccff; BORDER-BOTTOM: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; CURSOR: hand}";

strStyle += ".ltdexit {BACKGROUND-COLOR: #d0d0ce; BORDER-BOTTOM: #d0d0ce 1px solid; BORDER-TOP: #d0d0ce 1px solid; BORDER-LEFT: #d0d0ce 1px solid}";

strStyle += ".rtdfocus {BACKGROUND-COLOR: #ccccff; BORDER-BOTTOM: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; CURSOR: hand}";

strStyle += ".rtdexit {BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; BORDER-RIGHT: #ffffff 1px solid}";

strStyle += "</STYLE>";

document.write(strStyle);

}

function makeMenu()

{

var myMenu, item;

var homepage_cmd = "this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.webjx.com/'); return false;";

var favorate_cmd = "window.external.addFavorite('http://www.webjx.com/','网页教学网'); return false;";

var viewcode_cmd = "window.location = 'view-source:' + window.location.href";

myMenu = new contextMenu();

item = new contextItem("返回主页", "http://www.webjx.com/js/home.gif", "top.location='http://www.webjx.com/';", "menu");

myMenu.addItem(item);

item = new contextItem("设为主页", "http://www.webjx.com/js/home.gif", homepage_cmd, "menu");

myMenu.addItem(item);

item = new contextItem("添加到收藏夹", "http://www.webjx.com/js/favadd.gif", favorate_cmd, "menu");

myMenu.addItem(item);

item = new contextItem("联系作者", "http://www.webjx.com/js/mail.gif", "location.href='mailto:info@webjx.com'", "menu");

myMenu.addItem(item);

item = new contextItem("", "", "", "separator");

myMenu.addItem(item);

item = new contextItem("察看源码", "http://www.webjx.com/js/edit.gif", viewcode_cmd, "menu");

myMenu.addItem(item);

myMenu.show(this.document);

delete item;

delete myMenu;

}

function toggleMenu(isEnable)

{

if(isEnable)

document.oncontextmenu = showMenu;

else

document.oncontextmenu = new function() {return true;};

}

writeStyle();

makeMenu();

document.onclick = hideMenu;

document.oncontextmenu = showMenu;

file://-->

</script>

</HEAD>

<body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">

<table border="0" width="100%" height="100%" cellpadding="0" cellspacing="3">

<tr><td valign="top">

<div id="docBoard" style="width: 100%">

超酷的XP风格的网页右键菜单特效代码http://www.webjx.com/htmldata/sort/5.html

</div>

</td>

<td valign="top" align="right">

<p><input type="checkbox" name="closerm" onclick="toggleMenu(!this.checked);">关闭右键菜单</p>

</td>

</tr>

</table>

</body>

</HTML>

[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有