• JS仿Windows的右键菜单_网页代码站(www.webdm.cn)


    1 <HTML>
    2 <HEAD>
    3 <title>JS仿Windows的右键菜单_网页代码站(www.webdm.cn)</title>
    4 <STYLE type=text/css>BODY {
    5 FONT-SIZE: 12px;
    6 }
    7 .info{FONT-SIZE: 14px;color:#FFFFFF;font-family:@Tahoma,@宋体;width:20px}
    8 TABLE {
    9 CURSOR: default; FONT-SIZE: 12px; MARGIN: 0px
    10 }
    11 TR {
    12 HEIGHT: 20px
    13 }
    14 TR.over {
    15 BACKGROUND-COLOR: #000080; COLOR: #ffffff; CURSOR: default; FONT-SIZE: 12px
    16 }
    17 TR.out {
    18 BACKGROUND-COLOR: #efefef; COLOR: #000000; FONT-SIZE: 12px
    19 }
    20 DIV.rm_div {
    21 BACKGROUND-COLOR: #efefef; BORDER-BOTTOM: #ffffff 1px outset; BORDER-LEFT: #ffffff 1px outset; BORDER-RIGHT: #ffffff 1px outset;
    22
    23 BORDER-TOP: #ffffff 1px outset; DISPLAY: none; FILTER: Alpha(Opacity='95'); HEIGHT: 0px; PADDING-BOTTOM: 1px; PADDING-LEFT: 1px; PADDING-RIGHT:
    24
    25 1px; PADDING-TOP: 1px; POSITION: absolute; WIDTH: 0px
    26 }
    27 HR.sperator {
    28 BORDER-BOTTOM: #ffffff 1px inset; BORDER-LEFT: #ffffff 1px inset; BORDER-RIGHT: #ffffff 1px inset; BORDER-TOP: #ffffff 1px inset; WIDTH:
    29
    30 95%
    31 }
    32 .w2kfont {
    33 FONT-FAMILY: Tahoma; FONT-SIZE: 8pt
    34 }
    35 </STYLE>
    36
    37 <SCRIPT language=JScript>
    38 <!--
    39 function RightMenu()
    40 {
    41 this.AddExtendMenu=AddExtendMenu;
    42 this.AddItem=AddItem;
    43 this.GetMenu=GetMenu;
    44 this.HideAll=HideAll;
    45 this.I_OnMouseOver=I_OnMouseOver;
    46 this.I_OnMouseOut=I_OnMouseOut;
    47 this.I_OnMouseUp=I_OnMouseUp;
    48 this.P_OnMouseOver=P_OnMouseOver;
    49 this.P_OnMouseOut=P_OnMouseOut;
    50 A_rbpm = new Array();
    51 HTMLstr = "";
    52 HTMLstr += "<!-- RightButton PopMenu -->\n";
    53 HTMLstr += "\n";
    54 HTMLstr += "<!-- PopMenu Starts -->\n";
    55 HTMLstr += "<div id='E_rbpm' class='rm_div'>\n";
    56 HTMLstr += "<table width='100%' border='0' cellspacing='0'>\n";
    57 HTMLstr += "<tr><td height='264' width='20' valign='bottom' bgcolor='#000000' onclick=window.event.cancelBubble=true; class=info>娃海作制";
    58 HTMLstr += "</td><td height='264' width='120' style='padding: 1' valign='bottom'>\n";
    59 HTMLstr += "<table width='100%' border='0' cellspacing='0'>\n";
    60 HTMLstr += "<!-- Insert A Extend Menu or Item On Here For E_rbpm -->\n";
    61 HTMLstr += "</table></td></tr></table>\n";
    62 HTMLstr += "</div>\n";
    63 HTMLstr += "<!-- Insert A Extend_Menu Area on Here For E_rbpm -->";
    64 HTMLstr += "\n";
    65 HTMLstr += "<!-- PopMenu Ends -->\n";
    66 }
    67 function AddExtendMenu(id,img,wh,name,parent)
    68 {
    69 var TempStr = "";
    70
    71 eval("A_"+parent+".length++");
    72 eval("A_"+parent+"[A_"+parent+".length-1] = id");
    73 TempStr += "<div id='E_"+id+"' class='rm_div'>\n";
    74 TempStr += "<table width='100%' border='0' cellspacing='0'>\n";
    75 TempStr += "<!-- Insert A Extend Menu or Item On Here For E_"+id+" -->";
    76 TempStr += "</table>\n";
    77 TempStr += "</div>\n";
    78 TempStr += "<!-- Insert A Extend_Menu Area on Here For E_"+id+" -->";
    79 TempStr += "<!-- Insert A Extend_Menu Area on Here For E_"+parent+" -->";
    80 HTMLstr = HTMLstr.replace("<!-- Insert A Extend_Menu Area on Here For E_"+parent+" -->",TempStr);
    81
    82 eval("A_"+id+" = new Array()");
    83 TempStr = "";
    84 TempStr += "<!-- Extend Item : P_"+id+" -->\n";
    85 TempStr += "<tr id='P_"+id+"' class='out'";
    86 TempStr += " onmouseover='P_OnMouseOver(\""+id+"\",\""+parent+"\")'";
    87 TempStr += " onmouseout='P_OnMouseOut(\""+id+"\",\""+parent+"\")'";
    88 TempStr += " onmouseup=window.event.cancelBubble=true;";
    89 TempStr += " onclick=window.event.cancelBubble=true;";
    90 TempStr += "><td nowrap>";
    91 TempStr += "<font face='Wingdings' style='font-size:18px'>0</font> "+name+" </td><td style='font-family: webdings; text-align: ;'>4";
    92 TempStr += "</td></tr>\n";
    93 TempStr += "<!-- Insert A Extend Menu or Item On Here For E_"+parent+" -->";
    94 HTMLstr = HTMLstr.replace("<!-- Insert A Extend Menu or Item On Here For E_"+parent+" -->",TempStr);
    95 }
    96 function AddItem(id,img,wh,name,parent,location)
    97 {
    98 var TempStr = "";
    99 var ItemStr = "<!-- ITEM : I_"+id+" -->";
    100 if(id == "sperator")
    101 {
    102 TempStr += ItemStr+"\n";
    103 TempStr += "<tr class='out' onclick='window.event.cancelBubble=true;' onmouseup='window.event.cancelBubble=true;'><td colspan='2'
    104
    105 height='1'><hr class='sperator'></td></tr>";
    106 TempStr += "<!-- Insert A Extend Menu or Item On Here For E_"+parent+" -->";
    107 HTMLstr = HTMLstr.replace("<!-- Insert A Extend Menu or Item On Here For E_"+parent+" -->",TempStr);
    108 return;
    109 }
    110 if(HTMLstr.indexOf(ItemStr) != -1)
    111 {
    112 alert("I_"+id+"already exist!");
    113 return;
    114 }
    115 TempStr += ItemStr+"\n";
    116 TempStr += "<tr id='I_"+id+"' class='out'";
    117 TempStr += " onmouseover='I_OnMouseOver(\""+id+"\",\""+parent+"\")'";
    118 TempStr += " onmouseout='I_OnMouseOut(\""+id+"\")'";
    119 TempStr += " onclick='window.event.cancelBubble=true;'";
    120 if(location == null)
    121 TempStr += " onmouseup='I_OnMouseUp(\""+id+"\",\""+parent+"\",null)'";
    122 else
    123 TempStr += " onmouseup='I_OnMouseUp(\""+id+"\",\""+parent+"\",\""+location+"\")'";
    124 TempStr += "><td nowrap>";
    125 TempStr +="<font face='Wingdings' style='font-size:18px'>"+wh+"</font> "+ name+" ";//以Wingdings字体做为图片,要改成图片,请在这里更改
    126 TempStr += "</td><td></td></tr>\n";
    127 TempStr += "<!-- Insert A Extend Menu or Item On Here For E_"+parent+" -->";
    128 HTMLstr = HTMLstr.replace("<!-- Insert A Extend Menu or Item On Here For E_"+parent+" -->",TempStr);
    129 }
    130 function GetMenu()
    131 {
    132 return HTMLstr;
    133 }
    134 function I_OnMouseOver(id,parent)
    135 {
    136 var Item;
    137 if(parent != "rbpm")
    138 {
    139 var ParentItem;
    140 ParentItem = eval("P_"+parent);
    141 ParentItem.className="over";
    142 }
    143 Item = eval("I_"+id);
    144 Item.className="over";
    145 HideAll(parent,1);
    146 }
    147 function I_OnMouseOut(id)
    148 {
    149 var Item;
    150 Item = eval("I_"+id);
    151 Item.className="out";
    152 }
    153 function I_OnMouseUp(id,parent,location)
    154 {
    155 var ParentMenu;
    156 window.event.cancelBubble=true;
    157 OnClick();
    158 ParentMenu = eval("E_"+parent);
    159 ParentMenu.display="none";
    160 if(location == null)
    161 eval("Do_"+id+"()");
    162 else
    163 window.open(location);
    164 }
    165 function P_OnMouseOver(id,parent)
    166 {
    167 var Item;
    168 var Extend;
    169 var Parent;
    170 if(parent != "rbpm")
    171 {
    172 var ParentItem;
    173 ParentItem = eval("P_"+parent);
    174 ParentItem.className="over";
    175 }
    176 HideAll(parent,1);
    177 Item = eval("P_"+id);
    178 Extend = eval("E_"+id);
    179 Parent = eval("E_"+parent);
    180 Item.className="over";
    181 Extend.style.display="block";
    182 Extend.style.posLeft=document.body.scrollLeft+Parent.offsetLeft+Parent.offsetWidth-4;
    183 if(Extend.style.posLeft+Extend.offsetWidth > document.body.scrollLeft+document.body.clientWidth)
    184 Extend.style.posLeft=Extend.style.posLeft-Parent.offsetWidth-Extend.offsetWidth+8;
    185 if(Extend.style.posLeft < 0) Extend.style.posLeft=document.body.scrollLeft+Parent.offsetLeft+Parent.offsetWidth;
    186 Extend.style.posTop=Parent.offsetTop+Item.offsetTop+1;
    187 if(Extend.style.posTop+Extend.offsetHeight > document.body.scrollTop+document.body.clientHeight)
    188 Extend.style.posTop=document.body.scrollTop+document.body.clientHeight-Extend.offsetHeight;
    189 if(Extend.style.posTop < 0) Extend.style.posTop=0;
    190 }
    191 function P_OnMouseOut(id,parent)
    192 {
    193 }
    194 function HideAll(id,flag)
    195 {
    196 var Area;
    197 var Temp;
    198 var i;
    199 if(!flag)
    200 {
    201 Temp = eval("E_"+id);
    202 Temp.style.display="none";
    203 }
    204 Area = eval("A_"+id);
    205 if(Area.length)
    206 {
    207 for(i=0; i < Area.length; i++)
    208 {
    209 HideAll(Area[i],0);
    210 Temp = eval("E_"+Area[i]);
    211 Temp.style.display="none";
    212 Temp = eval("P_"+Area[i]);
    213 Temp.className="out";
    214 }
    215 }
    216 }
    217
    218 document.onmouseup=OnMouseUp;
    219 document.onclick=OnClick;
    220 function OnMouseUp()
    221 {
    222 if(window.event.button == 2)
    223 {
    224 var PopMenu;
    225 PopMenu = eval("E_rbpm");
    226 HideAll("rbpm",0);
    227 PopMenu.style.display="block";
    228 PopMenu.style.posLeft=document.body.scrollLeft+window.event.clientX;
    229 PopMenu.style.posTop=document.body.scrollTop+window.event.clientY;
    230 if(PopMenu.style.posLeft+PopMenu.offsetWidth > document.body.scrollLeft+document.body.clientWidth)
    231 PopMenu.style.posLeft=document.body.scrollLeft+document.body.clientWidth-PopMenu.offsetWidth;
    232 if(PopMenu.style.posLeft < 0) PopMenu.style.posLeft=0;
    233 if(PopMenu.style.posTop+PopMenu.offsetHeight > document.body.scrollTop+document.body.clientHeight)
    234 PopMenu.style.posTop=document.body.scrollTop+document.body.clientHeight-PopMenu.offsetHeight;
    235 if(PopMenu.style.posTop < 0) PopMenu.style.posTop=0;
    236 }
    237 }
    238 function OnClick()
    239 {
    240 HideAll("rbpm",0);
    241 }
    242 // Add Your Function on following
    243 function Do_viewcode(){window.location="view-source:"+window.location.href;}
    244 function Do_help(){window.showHelp(window.location);}
    245 function Do_exit() {window.close();}
    246 function Do_refresh() {window.location.reload();}
    247 function Do_back() {history.back();}
    248 function Do_forward() {history.forward();}
    249 function Do_help(){alert("帮助")}
    250 -->
    251 </SCRIPT>
    252 <META content="MSHTML 5.00.2920.0" name=GENERATOR></HEAD>
    253 <BODY bgColor=#336699 oncontextmenu=window.event.returnValue=false>
    254 <DIV id=snwcwt> 请点击右键</DIV>
    255 <SCRIPT language=JScript>
    256 <!--
    257 var menu = new RightMenu();
    258 menu.AddItem("update","start_update","4","<font class=w2kfont>Web Update</font>","rbpm","http://baidu.com/");
    259 menu.AddItem("suan","suan","a","鱼米之乡","rbpm","http://baidu.com");
    260 menu.AddItem("sperator","","","","rbpm",null);
    261 menu.AddExtendMenu("program","start_pro","24","程序<font class=w2kfont>(<u>P</u>)</font>","rbpm",null);
    262 menu.AddExtendMenu("p_acc","folder","+","附件","program",null);
    263 menu.AddItem("p_acc1","html","+","<font class=w2kfont>Microsoft FrontPage 2000</font>","program","51w/");
    264 menu.AddItem("p_acc2","html","+","<font class=w2kfont>Norton AntiVirus Corporate Edition</font>","program","http://baidu.com");
    265 menu.AddExtendMenu("p_lgame","folder","16","小游戏","p_acc",null);
    266 menu.AddItem("p_game1","folder","+","扫雷","p_lgame","http://baidu.com/");
    267 menu.AddItem("p_game2","folder","+","超级玛力","p_lgame","http://baidu.com/");
    268 menu.AddExtendMenu("doc","start_doc","24","文档<font class=w2kfont>(<u>D</u>)</font>","rbpm",null);
    269 menu.AddItem("d_photo","folder","+","官方博客","doc",null);
    270 menu.AddExtendMenu("fav","start_fav","24","收藏<font class=w2kfont>(<u>A</u>)</font>","rbpm",null);
    271 menu.AddExtendMenu("f_bbs","folder","16","论坛","fav",null);
    272 menu.AddItem("f_bbs2","html","+","百度搜索","f_bbs","http://baidu.com/");
    273 menu.AddItem("f_bbs3","html","+","网页代码站","f_bbs","http://www.webdm.cn/");
    274 menu.AddExtendMenu("f_webpage","folder","16","网页制作","fav",null);
    275 menu.AddItem("f_webpage1","html","","<font disabled>(空)</font>","f_webpage","http://baidu.com");
    276 menu.AddExtendMenu("f_study","folder","16","网上学习","fav",null);
    277 menu.AddItem("f_s1","html","","<font disabled>(空)</font>","f_study","http://matrix.hongen.com/forum/");
    278 menu.AddExtendMenu("f_link","folder","16","友情链接","fav",null);
    279 menu.AddItem("f_link1","html","+","CodeFans.net","f_link","http://baidu.com");
    280 menu.AddExtendMenu("setting","start_set","24","设置<font class=w2kfont>(<u>S</u>)</font>","rbpm",null);
    281 menu.AddItem("s_panel","folder","+","控制面板(C)","setting","http://baidu.com");
    282 menu.AddItem("sperator","","","","setting",null);
    283 menu.AddItem("s_data","s_user","+","用户资料(D)","setting","http://baidu.com");
    284 menu.AddItem("s_display1","s_taskbar","+","任务栏和开始菜单(T)","setting","http://baidu.com");
    285 menu.AddExtendMenu("find","start_find","24","查找<font class=w2kfont>(<u>F</u>)","rbpm",null);
    286 menu.AddItem("l_search","search","4","文件或文件夹上(<u>F</u>)...","find","http://baidu.com");
    287 menu.AddItem("u_search","f_user","4","用户(<u>P</u>)...","find","http://baidu.com");
    288 menu.AddItem("help","start_help","V","&nbsp;帮助<font class=w2kfont>(<u>H</u>)</font>","rbpm",null);
    289 menu.AddItem("sperator","","","","rbpm",null);
    290 menu.AddItem("logoff","start_logoff","v","&nbsp;注销<font class=w2kfont>(<u>L</u>)</font>","rbpm",null);
    291 menu.AddItem("shut","start_shut","x","退出<font class=w2kfont>(<u>U</u>)</font>","rbpm",null);
    292 document.writeln(menu.GetMenu());
    293 -->
    294 </SCRIPT>
    295 </TD></TR>
    296 </TABLE>
    297 </BODY>
    298 </HTML>
    299 <br>
    300 <a href="http://www.webdm.cn">网页代码站</a> - 最专业的代码下载网站 - 致力为中国站长提供有质量的代码!

    文章来自:http://www.webdm.cn/webcode/11a5e1ce-0e6d-4558-a27a-f226a88cd1ae.html

  • 相关阅读:
    理解Java虚拟机——Java内存模型管理
    Java 使用fastjson 将 json字符串写到文件中去
    java 如何调用 linux or mac 命令行
    MacOS 编译 openjdk8 并导入 Clion 调试
    linux ls 命令超级详解
    小 Q 与树 (点分治)
    mysql 索引策略
    java中serialVersionUID作用
    通过源码分析Spring Security用户认证流程
    使用PowerMockRunner和Mockito编写单元测试用例详解
  • 原文地址:https://www.cnblogs.com/webdm/p/1922727.html
Copyright © 2020-2023  润新知