📄 menu.js
字号:
var oPopup = window.createPopup();
function Item(text, url) {
this.text = text;
this.url = url;
};
function Menu() {
this.menuLeft = 0;
this.menuTop = 0;
this.item = [];
};
Menu.prototype.add = function (text, url) {
this.item[this.item.length] = new Item(text, url);
};
/*
//这两个是获得表格绝对位置的方法,很有用的说
function getLeftIE(x,m) {
var dx=0;
if (x.tagName=="TD"){
dx=x.offsetLeft;
} else if (x.tagName=="TABLE") {
dx=x.offsetLeft;
if (m) {
dx+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false;
}
}
return dx+(x.parentElement.tagName=="BODY"?0:getLeftIE(x.parentElement,m));
};
function getTopIE(x,m) {
var dy=0;
if (x.tagName=="TR"){
dy=x.offsetTop;
} else if (x.tagName=="TABLE") {
dy=x.offsetTop;
if (m) {
dy+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; }
}
return dy+(x.parentElement.tagName=="BODY"?0:getTopIE(x.parentElement,m));
};
*/
//显示菜单
Menu.prototype.showMenu = function (event,number) {
this.menuLeft = 100;
this.menuTop = 83;
/*
//定义打开的oPopup的宽度,高度
var width = 100;
var height = this.item.length *20;
//清空oPopup的内容,否则每次调用都只会在后面接着写
oPopup.document.body.innerHTML = "";
var oPopBody = oPopup.document.body;
oPopup.show(this.menuLeft, 69, width, height + 10, document.body);
oPopup.document.open;
//让oPopup在鼠标离开时自动隐藏。
oPopup.document.write("<body leftmargin=0 topmargin=0 scroll=no style='border:0 px;'> ");
//用document.write()写菜单内容
oPopup.document.write("<table width=100% height=100% style='border-collapse:collapse; border:1px solid #CCC;'>");
for(var i=0; i<this.item.length; i++)
{
oPopup.document.write("<tr><td style='padding-left:22px;background-color:#336699;cursor: hand; font-size : 13px; color:#E0E0E0;text-align : left;vertical-align : center;CURSOR: hand' onmouseover=this.bgColor='#C2D2E5'; onmouseout=this.bgColor='#cccccc'; height='20' onclick='parent.top.location.href=\""+ this.item[i].url +"\"';>"+ this.item[i].text +"</td></tr>");
}
oPopup.document.write("</table>");
oPopup.document.write("</body>");
*/
var menuHtml = "<div id='secondMenu' onmouseout='timer=setTimeout(\"menu" + number + ".hideMenu()\",500)' onmousemove='clearTimeout(timer)'><ul>";
for(var i=0; i<this.item.length; i++)
{
menuHtml = menuHtml + "<li><a href='.."+ this.item[i].url +"' target='middle'> "+ this.item[i].text +" </a></li>";
}
menuHtml = menuHtml + "</ul></div>";
document.getElementById("subMenu").innerHTML = menuHtml;
};
Menu.prototype.hideMenu = function () {
document.getElementById("subMenu").innerHTML = "";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -