menu.js

来自「从网上下载的关于学习动态链接库的连载教程」· JavaScript 代码 · 共 123 行

JS
123
字号
//下拉菜单相关代码
 var h;
 var w;
 var l;
 var t;
 var topMar = 1;
 var leftMar = -10;
 var space = 1;
 var isvisible;
 var global = window.document
 global.fo_currentMenu = null
 global.fo_shadows = new Array

function HideMenu() 
{
 var mX;
 var mY;
 var vDiv;
 var mDiv;
if (isvisible == true)
{
vDiv = document.all("menuDiv");
mX = window.event.clientX + document.body.scrollLeft;
mY = window.event.clientY + document.body.scrollTop;
if ((mX < parseInt(vDiv.style.left)) || (mX > parseInt(vDiv.style.left)+vDiv.offsetWidth) || (mY < parseInt(vDiv.style.top)-h) || (mY > parseInt(vDiv.style.top)+vDiv.offsetHeight)){
vDiv.style.visibility = "hidden";
isvisible = false;
}
}
}

function ShowMenu(vMnuCode,tWidth) {

vSrc = window.event.srcElement;
vMnuCode = "<table id='submenu' cellspacing=1 cellpadding=3 style='width:"+tWidth+"'  onmouseout='HideMenu()'><tr height=23><td nowrap align=left >" + vMnuCode + "</td></tr></table>";
h = vSrc.offsetHeight;
w = vSrc.offsetWidth;
l = vSrc.offsetLeft + leftMar+4;
t = vSrc.offsetTop + topMar + h + space-2;
vParent = vSrc.offsetParent;
while (vParent.tagName.toUpperCase() != "BODY")
{
l += vParent.offsetLeft;
t += vParent.offsetTop;
vParent = vParent.offsetParent;
}

menuDiv.innerHTML = vMnuCode;

menuDiv.style.top = t;
menuDiv.style.left = l;
menuDiv.style.visibility = "visible";
isvisible = true;

makeRectangularDropShadow(submenu, 4)
}

function makeRectangularDropShadow(el, color, size)
{

var i;
for (i=size; i>0; i--)
{
var rect = document.createElement('div');
var rs = rect.style
rs.position = 'absolute';
rs.left = (el.style.posLeft + i) + 'px';
rs.top = (el.style.posTop + i) + 'px';
rs.width = el.offsetWidth + 'px';
rs.height = el.offsetHeight + 'px';
rs.zIndex = el.style.zIndex - i;
var opacity = 1 - i / (i + 1);
rs.filter = 'alpha(opacity=' + (100 * opacity) + ')';
el.insertAdjacentElement('afterEnd', rect);
global.fo_shadows[global.fo_shadows.length] = rect;
}
}
//个人设置
var ltgx= '<a style=font-size:9pt;line-height:10pt; href=\"forum_admin.aspx\">基本信息管理</a>    <a style=font-size:9pt;line-height:14pt; href=\"forumsort.aspx\">版块管理</a>    <a style=font-size:9pt;line-height:14pt; href=\"forumlink.aspx\">友情连接管理</a>    <a style=font-size:9pt;line-height:14pt; href=\"forumAdv.aspx\">公告管理</a>    <a style=font-size:9pt;line-height:14pt; href=\"forumarticle.aspx\">文章管理</a>    <a style=font-size:9pt;line-height:14pt; href=\"forummoderator.aspx\">斑竹管理</a>    <a style=font-size:9pt;line-height:14pt; href=\"forum_baduser.aspx\">屏蔽特定用户</a>'

<!--
//图片按比例缩放
var flag=false;

function DrawImage(ImgD ,iwidth,iheight)
{
        var image=new Image();
	// var iwidth = 640; 定义允许图片宽度
	// var iheight = 640; 定义允许图片高度
	image.src=ImgD.src;
	if(image.width>0 && image.height>0)
	{
	        flag=true;
		if(image.width/image.height>= iwidth/iheight)
		{
		        if(image.width>iwidth)
			{
			        ImgD.width=iwidth;
				ImgD.height=(image.height*iwidth)/image.width;
			}
			else
			{
			        ImgD.width=image.width;
				ImgD.height=image.height;
			}
			ImgD.alt=image.width+"×"+image.height;
		}
		else{
		        if(image.height>iheight)
			{
		                ImgD.height=iheight;
				ImgD.width=(image.width*iheight)/image.height;
			}
			else
			{
		                ImgD.width=image.width;
				ImgD.height=image.height;
			}
			ImgD.alt=image.width+"×"+image.height;
		}
	}
}
//-->

⌨️ 快捷键说明

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