中文(繁体)
<HTML> <HEAD> <TITLE></TITLE> <META content="text/html; charset=gb2312" http-equiv=Content-Type> <META content="MSHTML 5.00.2920.0" name=GENERATOR> <script > <!-- // 選單物件function contextMenu() { this.items = new Array(); this.addItem = function (item) { this.items[this.items.length] = item; } this.show = function (oDoc) { var strShow = "";變數我; strShow = "<div id="rightmenu" style="背景顏色:#ffffff;邊框:#000000 1px 實線;左:0 像素;位置:絕對;頂部:0 像素;可見性:隱藏; Z-索引:10">"; strShow += "<表格邊框="0" 高度=""; strShow += this.items.length * 20; strShow += "" cellpadding="0" cellspacing="0" >”; strShow += "<tr height="3"><td bgcolor="#d0d0ce" width="2"></td><td>"; strShow += "<表格邊框="0" 寬度="100%" 高度="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 += "<表格邊框="0" 寬度="100%" 高度="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 += "<表格邊框="0" 寬度="100%" 高度="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); } } // 選單項目物件 function contextItem(text, icon, cmd, type) { this.text = text ?文字 : "";這.icon = 圖示 ?圖示 : "";這個.cmd = cmd ? cmd:「」; this.type = 類型 ?類型:“菜單”; this.show = function (oDoc) { var strShow = ""; if(this.type == "選單") { 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 += " "; else { strShow += "<img border="0" src=""; strShow += this.icon; strShow += "" width="16" height="16" style= "位置:相對"></img>"; } strShow += "</td><td class="mtdexit">"; strShow += this.text; strShow += "</td><td class="rtdexit" width="5"> </td></tr>"; } else if (this.type == "separator") { strShow += "<tr><td class="ltdexit"> </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 = 事件.clientY; var obj = document.getElementById("rightmenu"); if (obj == null) 傳回 true; ox = document.body.clientWidth; oy = document.body.clientHeight; if(x > ox || y > oy) 返回 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 = "可見";返回假; } function hideMenu() { if(event.button == 0) { var obj = document.getElementById("rightmenu"); if (obj == null) 傳回 true; obj.style.visibility = "隱藏"; obj.style.posLeft = 0; obj.style.posTop = 0; } } 函數 writeStyle() { var strStyle = ""; strStyle += "<STYLE type=text/css>"; strStyle += "表格{字型系列: "Tahoma","Verdana","宋體"; 字型大小: 9pt}"; strStyle += ".mtdfocus {背景顏色:#ccccff;邊框底部:#000000 1px 實心;邊框頂部:#000000 1px 實心;遊標:手}"; strStyle += ".mtdexit {背景顏色: #ffffff; 邊框底部: #ffffff 1px 實心; 頂部邊框: #ffffff 1px 實心}"; strStyle += ".ltdfocus {背景顏色:#ccccff;底部邊框:#000000 1px 實心;頂部邊框:#000000 1px 實心;左框:#000000 1px 實心;遊標:手}"; strStyle += ".ltdexit {背景顏色: #d0d0ce; 邊框底部: #d0d0ce 1px 實心; 頂部邊框: #d0d0ce 1px 實心; 左邊框: #d0d0ce 1px 實心}"; strStyle += ".rtdfocus {背景顏色:#ccccff;底部邊框:#000000 1px 實心;頂部邊框:#000000 1px 實心;右邊框:#000000 1px 實心;遊標:手手}"; strStyle += ".rtdexit {背景顏色:#ffffff;底部邊框:#ffffff 1px 實心;頂部邊框:#ffffff 1px 實心;右邊框:#ffffff 1px 實心}"; strStyle += "</STYLE>";文檔.write(strStyle); } 函數 makeMenu() { var myMenu, item; var homepage_cmd = "this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.downcodes.com/'); return false;"; var favorite_cmd = "window.external.addFavorite('http://www.downcodes.com/','網站建立學院'); return false;"; var viewcode_cmd = "window.location = '查看來源:' + window.location.href"; myMenu = 新的 contextMenu(); item = new contextItem("返回首頁", "", "top.location='http://www.downcodes.com/';", "選單"); myMenu.addItem(項目); item = new contextItem("設為首頁", "", homepage_cmd, "選單"); myMenu.addItem(項目); item = new contextItem("加入到收藏夾", "",favorate_cmd, "menu"); myMenu.addItem(項目); item = new contextItem("聯絡作者", "", "location.href='mailto:info@downcodes.com'", "選單"); myMenu.addItem(項目); item = new contextItem("", "", "", "分隔符號"); myMenu.addItem(項目); item = new contextItem("察看原始碼", "", viewcode_cmd, "menu"); myMenu.addItem(項目); myMenu.show(this.document);刪除項目;刪除我的菜單; } 函式toggleMenu(isEnable) { if(isEnable) document.oncontextmenu = showMenu; else document.oncontextmenu = new function() {return true;}; } writeStyle();製作菜單(); document.onclick = hideMenu; document.oncontextmenu = showMenu;文件://--> </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.downcodes.com/htmldata/sort/5.html </div> </td> <td valign="top"align="right"> <p><輸入類型="checkbox" name="closerm" onclick="toggleMenu(!this.checked);">關閉右鍵選單</p> </td> </tr> </table> </body> </HTML>