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

📄 hiermenus.js

📁 电脑知识十万个为什么-v1.5注册版.zip
💻 JS
📖 第 1 页 / 共 2 页
字号:
	}
	else {
		this.fullHeight = this.scrollHeight;
		this.showIt(false);
		this.moveTo = moveTo;
	}
}

function popUp(menuName,e){
	if (NS4 && NSresized) startIt();
	if (!isLoaded) return;
	linkEl = (NS4) ? e.target : event.srcElement;
	if (clickStart) linkEl.onclick = popMenu;
	if (!beingCreated && !areCreated) startIt();
	linkEl.menuName = (IE4) ? menuName : "document."+menuName;	
	if (!clickStart) popMenu(e);
}

function popMenu(e){
	if (!isLoaded || !areCreated) return true;

	eType = (NS4) ? e.type : event.type;
	if (clickStart && eType != "click") return true;
	hideAll();

	linkEl = (NS4) ? e.target : event.srcElement;
	
	currentMenu = eval(linkEl.menuName);
	currentMenu.hasParent = false;
	currentMenu.menuObj.treeParent.startChild = currentMenu;
	
	if (IE4) menuLocBod = document.body;
	xPos = (currentMenu.menuLeft) ? currentMenu.menuLeft : (NS4) ? e.pageX : (event.clientX + menuLocBod.scrollLeft);
	yPos = (currentMenu.menuTop) ? currentMenu.menuTop : (NS4) ? e.pageY : (event.clientY + menuLocBod.scrollTop);

	currentMenu.moveTo(xPos,yPos);
	currentMenu.keepInWindow()
	currentMenu.isOn = true;
	currentMenu.showIt(true);

	return false;
}

function menuOver(e) {
	this.isOn = true;
	isOverMenu = true;
	currentMenu = this;
	if (this.hideTimer) clearTimeout(this.hideTimer);
}

function menuOut() {
	if (IE4 && event.srcElement.contains(event.toElement)) return;
	this.isOn = false;
	isOverMenu = false;
	status = "";
	if (!clickKill) allTimer = setTimeout("currentMenu.hideTree()",10);  
}

function itemOver(){
	if (keepHilite) {
		if (this.container.currentItem && this.container.currentItem != this) {
			if (NS4) {
				this.container.currentItem.bgColor = this.menuObj.menuBGColor;
				if (NSfontOver) this.container.currentItem.txtLyr.dw(this.container.currentItem.htmStr);
			}
			else {
				with (this.container.currentItem.style) {
					backgroundColor = this.menuObj.menuBGColor;
					color = this.menuObj.menuFontColor;
				}
			}
		}
	}

	if (IE4) {
		if (event.srcElement.tagName == "IMG") return;
		this.style.backgroundColor = this.menuObj.menuBGOver;
		this.style.color = this.menuObj.menuFontOver;
	}
	else {
		this.bgColor = this.menuObj.menuBGOver;
		if (NSfontOver)	this.txtLyr.dw(this.htmStrOver);
	}

	status = this.linkText;

	this.container.currentItem = this;

	if (this.container.hasChildVisible) {
		this.container.hideChildren(this);
	}

	if (this.hasMore) {
		horOffset = (this.menuObj.menuWidth - this.container.childOverlap);

		if (NS4) {
			this.childX = this.container.left + horOffset;
			this.childY = this.pageY + childOffset;
		}
		else {
			this.childX = this.container.style.pixelLeft + horOffset;
			this.childY = this.offsetTop + this.container.style.pixelTop + childOffset;
		}

		this.child.moveTo(this.childX,this.childY);
		this.child.keepInWindow();
		this.container.hasChildVisible = true;
		this.container.visibleChild = this.child;
		this.child.showIt(true);
	}
}

function itemOut() {
	if (IE4) {
    	if (event.srcElement.contains(event.toElement)
     || (event.fromElement.tagName=="IMG" && event.toElement.contains(event.fromElement)))
        return;
		if (!keepHilite) {
			this.style.backgroundColor = this.menuObj.menuBGColor;
			this.style.color = this.menuObj.menuFontColor;
		}
	}
	else {
		if (!keepHilite) {
			this.bgColor = this.menuObj.menuBGColor;
			if (NSfontOver) this.txtLyr.dw(this.htmStr);
		}
		if (!isOverMenu && !clickKill) {
			allTimer = setTimeout("currentMenu.hideTree()",10); 
		}
	}
}

function moveTo(xPos,yPos) {
	this.style.pixelLeft = xPos;
	this.style.pixelTop = yPos;
}

function showIt(on) {
	if (NS4) {
		this.visibility = (on) ? "show" : "hide";
		if (keepHilite && this.currentItem) {
			this.currentItem.bgColor = this.menuBGColor;
			if (NSfontOver) this.currentItem.txtLyr.dw(this.currentItem.htmStr);
		}
	}
	else {
		this.style.visibility = (on) ? "visible" : "hidden";
		if (keepHilite && this.currentItem) {
			with (this.currentItem.style) {
				backgroundColor = this.menuBGColor;
				color = this.menuFontColor;
			}
		}
	}
	this.currentItem = null;
}

function keepInWindow() {
	scrBars = 20;
	botScrBar = scrBars;
	rtScrBar = scrBars;
	if (NS4) {
		winRight = (pageXOffset + innerWidth) - rtScrBar;
		rightPos = this.left + this.menuWidth;
   
		if (rightPos > winRight) {
			if (this.hasParent) {
				parentLeft = this.parentMenu.left;
				newLeft = ((parentLeft-this.menuWidth) + this.childOverlap);
				this.left = newLeft;
			}
			else {
				dif = rightPos - winRight;
				this.left -= dif;
			}
		}

		winBot = (pageYOffset + innerHeight) - botScrBar ;
		botPos = this.top + this.fullHeight;

		if (botPos > winBot) {
			dif = botPos - winBot;
			this.top -= dif;
		}
		
		winLeft = pageXOffset;
		leftPos = this.left;

		if (leftPos < winLeft) {
			if (this.hasParent) {
				parentLeft = this.parentMenu.left;
				newLeft = ((parentLeft+this.menuWidth) - this.childOverlap);
				this.left = newLeft;
			}
			else {
				this.left = 5;
			}
		}
	}
	else {
    	winRight = (document.body.scrollLeft + document.body.clientWidth) - rtScrBar;
		rightPos = this.style.pixelLeft + this.menuWidth;
	
		if (rightPos > winRight) {
			if (this.hasParent) {
				parentLeft = this.parentMenu.style.pixelLeft;
				newLeft = ((parentLeft - this.menuWidth) + this.childOverlap);
				this.style.pixelLeft = newLeft;
			}
			else {
				dif = rightPos - winRight;
				this.style.pixelLeft -= dif;
			}
		}

		winBot = (document.body.scrollTop + document.body.clientHeight) - botScrBar;
		botPos = this.style.pixelTop + this.fullHeight;

		if (botPos > winBot) {
			dif = botPos - winBot;
			this.style.pixelTop -= dif;
		}
		
		winLeft = document.body.scrollLeft;
		leftPos = this.style.pixelLeft;

		if (leftPos < winLeft) {
			if (this.hasParent) {
				parentLeft = this.parentMenu.style.pixelLeft;
				newLeft = ((parentLeft+this.menuWidth) - this.childOverlap);
				this.style.pixelLeft = newLeft;
			}
			else {
				this.style.pixelLeft = 5;
			}
		}
	}
}

function linkIt() {
	if (this.linkText.indexOf("javascript")!=-1) eval(this.linkText)
	else location.href = this.linkText;
}

function popDown(menuName){
	if (!isLoaded || !areCreated) return;
	whichEl = eval(menuName);
	whichEl.isOn = false;
	if (!clickKill) whichEl.hideTop();
}

function hideAll() {
	for(i=1; i<topCount; i++) {
		temp = eval("elMenu" + i + ".startChild");
		temp.isOn = false;
		if (temp.hasChildVisible) temp.hideChildren();
		temp.showIt(false);
	}	
}

function hideTree() { 
	allTimer = null;
	if (isOverMenu) return;
	if (this.hasChildVisible) {
		this.hideChildren();
	}
	this.hideParents();
}

function hideTop() {
	whichEl = this;
	(clickKill) ? whichEl.hideSelf() : (this.hideTimer = setTimeout("whichEl.hideSelf()",mSecsVis));
}

function hideSelf() {
	this.hideTimer = null;
	if (!this.isOn && !isOverMenu) { 
		this.showIt(false);
	}
}

function hideParents() {
	tempMenu = this;
	while (tempMenu.hasParent) {
		tempMenu.showIt(false);
		tempMenu.parentMenu.isOn = false;		
		tempMenu = tempMenu.parentMenu;
	}
	tempMenu.hideTop();
}

function hideChildren(item) {
	tempMenu = this.visibleChild;
	while (tempMenu.hasChildVisible) {
		tempMenu.visibleChild.showIt(false);
		tempMenu.hasChildVisible = false;
		tempMenu = tempMenu.visibleChild;
	}

	if (!this.isOn || !item.hasMore || this.visibleChild != this.child) {
		this.visibleChild.showIt(false);
		this.hasChildVisible = false;
	}
}

function clicked() {
	if (!isOverMenu && currentMenu!=null && !currentMenu.isOn) {
		whichEl = currentMenu;
		whichEl.hideTree();
	}
}

window.onerror = handleErr;

function handleErr(){
	arAccessErrors = ["permission","access"];
	mess = arguments[0].toLowerCase();
	found = false;
	for (i=0;i<arAccessErrors.length;i++) {
		errStr = arAccessErrors[i];
		if (mess.indexOf(errStr)!=-1) found = true;
	}
	return found;
}

startIt();

//end

⌨️ 快捷键说明

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