⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menu.js

📁 本程序使用C#开发
💻 JS
字号:
//首先定义两个数组,一个是菜单文字,一个是链接
var MenuText = new Array(3);
var MenuEven = new Array(3);
MenuText[1] = ["新建","打开","关闭","保存","另存为","打印预览","打印"];
MenuText[2] = ["复制","粘贴","删除","填充"];
MenuText[3] = ["插入行","删除行","插入列","删除列","插入图片","合并"];

MenuEven[1] = ["cratenew()","myopen(this)","myclose()","save()","saveas()","preview()","print()"];
MenuEven[2] = ["copy()","paster()","delmessage()","fill()"];
MenuEven[3] = ["insertrow()","delrow()","insertcol()","delcol()","insertpic()","selected_area.unitTD()"];

//初始化一个oPopup对象

var oPopup = window.createPopup();

//这两个是获得表格绝对位置的方法,很有用
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));
}

//显示菜单
function ButtonClick(node,t)
{ 
	//首先得到鼠标所在的表格的位置
	var left = getLeftIE(node,true)+8; 
	var top = getTopIE(node,true)+node.offsetHeight;
	//定义打开的oPopup的宽度,高度
	var width = 80;
	var height = MenuText[t].length*20; 
	//清空oPopup的内容,否则每次调用都只会在后面接着写
	oPopup.document.body.innerHTML = "";
	var oPopBody = oPopup.document.body;
	oPopup.show(left,top, width, height, document.body); 
	oPopup.document.open;
	//让oPopup在鼠标离开时自动隐藏。
	oPopup.document.write("<body onclick=closemenu() leftmargin=0 topmargin=0 scroll=no style='border : 0 px;' onmouseover=clearTimeout(parent.popt); onmouseout=parent.popt=setTimeout('parent.oPopup.hide()',10);>");

	//用document.write()写菜单内容
	oPopup.document.write("<table width=100% height=100% style='border-collapse : collapse;'>");
	for(var i=0;i<MenuText[t].length;i++)
	{
	//
		oPopup.document.write("<tr><td width=15 background='Images/menuleft.gif'> </td><td style='border-top : #cccccc 1px solid;border-bottom : #666666 1px solid;border-left : #cccccc 1px solid;border-right : #666666 1px solid;mouse : hand; font-size : 12px; color:#000000;text-align : left;vertical-align : center;CURSOR: hand'  background='image/topbg.gif' bgcolor=#cccccc onmouseover=this.bgColor='#C2D2E5'; onmouseout=this.bgColor='#cccccc'; height='20'  onclick=parent."+MenuEven[t][i]+">"+MenuText[t][i]+"</td></tr>");//+MenuEven[t][i]+"
	}
	oPopup.document.write("</table>");
	oPopup.document.write("</body>")
}

//右键菜单代码
var rightmenutext = new Array(1);
var rightmenuevent = new Array(1);
rightmenutext[1] = ["复制","粘贴","合并"];
rightmenuevent[1] = ["copy()","paster()","selected_area.unitTD()"];
//显示右键菜单
function RightClick()
{ 
	//首先得到鼠标所在的表格的位置
	var left = event.x; 
	var top = event.y;
	//定义打开的oPopup的宽度,高度
	var width = 80;
	var height = rightmenutext[1].length*20; 
	//清空oPopup的内容,否则每次调用都只会在后面接着写
	oPopup.document.body.innerHTML = "";
	var oPopBody = oPopup.document.body;
	oPopup.show(left,top, width, height, document.body); 
	oPopup.document.open;
	//让oPopup在鼠标离开时自动隐藏。
	oPopup.document.write("<body leftmargin=0 topmargin=0 scroll=no style='border : 0 px;' onmouseover=clearTimeout(parent.popt); onmouseout=parent.popt=setTimeout('parent.oPopup.hide()',10);>");

	//用document.write()写菜单内容
	oPopup.document.write("<table width=100% height=100% style='border-collapse : collapse;'>");
	for(var i=0;i<rightmenutext[1].length;i++)
	{
	//
		oPopup.document.write("<tr><td width=15 background='Images/menuleft.gif'> </td><td style='border-top : #cccccc 1px solid;border-bottom : #666666 1px solid;border-left : #cccccc 1px solid;border-right : #666666 1px solid;mouse : hand; font-size : 12px; color:#000000;text-align : left;vertical-align : center;CURSOR: hand'  background='image/topbg.gif' bgcolor=#cccccc onmouseover=this.bgColor='#C2D2E5'; onmouseout=this.bgColor='#cccccc'; height='20'  onclick=parent."+rightmenuevent[1][i]+">"+rightmenutext[1][i]+"</td></tr>");//+MenuEven[t][i]+"
	}
	oPopup.document.write("</table>");
	oPopup.document.write("</body>")
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -