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

📄 menus.js

📁 一些面试题集 供大家参考 希望大家找到合适的工作
💻 JS
字号:
// MPC 9/08/2004
//	Task: 2573
//	Description: This Javascript is used to show and hide the menus defined by /assets/include/menus.inc for most common browsers.
//	The following functions are called from the /assets/include/leftnav.inc when mouse events occur.
//	It is currently limited to a maximum of three levels of depth.

var displayTime = 0;
var lastMenu = 0;
var layerTimer;
var opac = 0;
var curMenu = 0;
var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

//browser detection
var browserType

var formPage 
formPage = false

if (document.all) { browserType = "IE" } //ie
else if (document.getElementById){ browserType = "NS6" } //ns6: mozilla, firefox
else if (document.layers) { browserType = "NS4" } //ns4


function showMenu(sltMenu, which) {
	var tweakXposition = 0;
	var tweakYposition = 0;
	displayTime = 0;
	opac = 0;	
	
	curMenu = sltMenu;
	
	
	if (is_ie && formPage){
		//hide form elements that interfere with the menu
		eval("document.getElementById('ddPID').style.visibility ='hidden'");				
	}
			
		
	if((document.getElementById(sltMenu).style.visibility == 'visible')  && (sltMenu == lastMenu)) {
		clearTimeout(layerTimer);
		return;
	}
	
	// hide menus that do not need to be shown before displaying the new menu
	// Note: do not hide any menus if the current selected menu (sltmenu) is equivalent to the last selected menu 
	// or if it is a menu on the third level
	if(sltMenu != lastMenu && lastMenu != 0 && sltMenu != "menu1a" && sltMenu != "menu4a") {

		eval("document.getElementById('" + lastMenu + "').style.visibility ='hidden'");

		//hide 2nd level menus that link to a 3rd level menu
		//eval("document.getElementById('menu1').style.visibility ='hidden'");
	}
	//get position of the originating anchor tag in order to solidify the positioning menus for non-IE browsers.
	if(which != 0) {
		varcoords = getAnchorPosition(which);
		
		//add minor positional tweak for non-IE browser
		if(browserType != "IE") {
			tweakXposition = 2;
		}
		eval("document.getElementById('" + sltMenu + "').style.left = varcoords.x + 180 + tweakXposition");
		eval("document.getElementById('" + sltMenu + "').style.top = varcoords.y - 1");	
	}
	else
		varcoords = 0;
		
	// display new menu
	fadeIn();
	
	lastMenu = sltMenu;			// store the current selected menu so that we can hide it later
	clearTimeout(layerTimer);	// reset the timer since we want the current menu to be displayed for the full specified time
	
	return;
}

function hideMenu() {

		if(displayTime < 1) { // This code causes 1 increment of the below 500 ms to occur before hidding anything
			displayTime++;
		}
		else { // hide all menus
			eval("document.getElementById('menu1').style.visibility ='hidden'");	
			//eval("document.getElementById('menu1a').style.visibility ='hidden'");		
			//eval("document.getElementById('menu1b').style.visibility ='hidden'");
			//eval("document.getElementById('menu1c').style.visibility ='hidden'");
			//eval("document.getElementById('menu1d').style.visibility ='hidden'");
			//eval("document.getElementById('menu1e').style.visibility ='hidden'");
			eval("document.getElementById('menu2').style.visibility ='hidden'");
			eval("document.getElementById('menu3').style.visibility ='hidden'");
			eval("document.getElementById('menu4').style.visibility ='hidden'");
			//eval("document.getElementById('menu4a').style.visibility ='hidden'");		
			//eval("document.getElementById('menu4b').style.visibility ='hidden'");
			//eval("document.getElementById('menu4c').style.visibility ='hidden'");
			//eval("document.getElementById('menu4d').style.visibility ='hidden'");
			//eval("document.getElementById('menu4e').style.visibility ='hidden'");			
			eval("document.getElementById('menu5').style.visibility ='hidden'");
			//eval("document.getElementById('menu6').style.visibility ='hidden'");
			displayTime = 0;
			opac = 0;
			
		
			if (is_ie && formPage){
				//hide form elements that interfere with the menu
				eval("document.getElementById('ddPID').style.visibility ='visible'");				
			}
	
			
		}
		layerTimer=setTimeout("hideMenu()", 200); // call hideMenu again after 500 ms have gone by
}

function resetTimer() {
	displayTime = 0;
	clearTimeout(layerTimer);
}

// adds fade in effect to the displaying of the div tag
function fadeIn() {
//alert(curMenu);
	eval("document.getElementById('" + curMenu + "').style.visibility = 'visible'");
	if(opac < 96){
		opac+=32;
		eval("document.getElementById('" + curMenu + "').style.filter='alpha(opacity = " + opac + ")'");
		setTimeout('fadeIn()', 1);
	}
}

⌨️ 快捷键说明

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