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

📄 globals.js

📁 基于VS05和SQL05做的一个电子商务网站
💻 JS
📖 第 1 页 / 共 2 页
字号:
<!--
var mnu_active = false; // determines if a menu is active
var mnu_items = new Array(); // holds a collection of current active menus
var mnu_left = 0;
var mnu_right = 0;
var mnu_top = 0;
var mnu_bottom = 0;
var WinNum = 0; // init windows number

/* ----------------------------------------------------------- */
// Get browser information
/* ----------------------------------------------------------- */

var if_userAgent = navigator.userAgent.toLowerCase();
var opera = (if_userAgent.indexOf('opera') != -1); // is opera
var opera8 = ((if_userAgent.indexOf('opera 8') != -1 || if_userAgent.indexOf('opera/8') != -1) ? 1 : 0); // is opera8
var ns4 = (document.layers) ? true : false; // is netscape 4
var ie4 = (document.all && !document.getElementById) ? true : false; // is IE 4
var ie5 = (document.all && document.getElementById) ? true : false; // is IE 5+
var ns6 = (!document.all && document.getElementById) ? true : false; // is netscape 6

/* ----------------------------------------------------------- */
// Set-up document event handlers									   
/* ----------------------------------------------------------- */

if (ie4 || ie5 || opera) {
	document.onclick = if_hideAllMenusOnClick;
	document.onscroll = if_hideAllMenusOnClick;
	window.onresize = if_winResize;
}    
else if (ns6) { 
	document.addEventListener("mousedown", if_hideAllMenusOnClick, true);
	window.addEventListener("onresize", if_winResize, true);
} 
else if (ns4) {
	document.onmousedown = if_hideAllMenusOnClick;
	window.captureEvents(Event.MOUSEMOVE);
}

/* ----------------------------------------------------------- */
// Pre-load drop down menu images so they display correctly					   
/* ----------------------------------------------------------- */

function if_PreloadImages(CurrentSkin) {
	if (document.images)
	{
		arImageList = new Array ();
		var arImageSrc = new Array(CurrentSkin + "Images/Misc_Rating1.gif",
		CurrentSkin + "Images/Misc_Rating2.gif",
		CurrentSkin + "Images/Misc_Rating3.gif",
		CurrentSkin + "Images/Misc_Rating4.gif",
		CurrentSkin + "Images/Misc_Rating5.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Bold.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Bullets.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Center.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Fontcolor.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_FontcolorPrompt.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Grab.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Highlight.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_HighlightPrompt.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Indent.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_InsertImg.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Italics.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Justify.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Left.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Link.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_NumList.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Quote.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Right.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Sep.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Strike.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Subscript.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Superscript.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Toolsep.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Underline.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Unindent.gif",
		CurrentSkin + "Images/RichTextBoxIcons/tab_Edit_Off.gif",
		CurrentSkin + "Images/RichTextBoxIcons/tab_Edit_On.gif",
		CurrentSkin + "Images/RichTextBoxIcons/tab_Html_Off.gif",
		CurrentSkin + "Images/RichTextBoxIcons/tab_Html_On.gif");
			
		for (counter in arImageSrc) {
			arImageList[counter] = new Image();
			arImageList[counter].src = arImageSrc[counter];
		}
	}    
}

/* ----------------------------------------------------------- */
// Determine what object model we should use                   
/* ----------------------------------------------------------- */

function if_returnObjRef(objName) {

	var objReturn = '';
		if (ie5 || ns6 || opera)
		{
			objReturn = document.getElementById(objName);
		}
		else if (ie4)
		{
			objReturn = document.all[objName];
		}
		else if (ns4)
		{
			objReturn = document.layers[objName];
		}

	return objReturn

}

/* ----------------------------------------------------------- */
// Open Menu on MouseOver Event
/* ----------------------------------------------------------- */

function if_openMenuMouseOver(Caller, DivLayer, InnerHTML, Width) {

	if (mnu_active) {if_openMenu(Caller, DivLayer, InnerHTML, Width);}
		
}

/* ----------------------------------------------------------- */
// Open Menu on MouseClick Event
/* ----------------------------------------------------------- */

function if_openMenu(Caller, DivLayer, InnerHTML, Width) {
		
		// create unique identity for generated div layer
		DivLayer = DivLayer + "_" + Caller
		
		// create iframe to hold menu, this ensures we render over dropdownlists
		var Iframe = DivLayer + "_Iframe"
		
		// determine if we can create elements dynamically
		if (!document.createElement) {return false;}
		
		// check to see if item is already within active menu array if so just quit and return false
		for (count = 0; count < mnu_items.length; count++)	{
			if (mnu_items[count] == DivLayer) {
				return false;
			}
		}
		
		// hide any menus that maybe open
		if_hideAllMenus();
		
		// add active menu to array and set active state to true
		mnu_items[mnu_items.length] = DivLayer;
		mnu_active = true;
		
		// create the div layer container for this menu
		if_setDiv(InnerHTML, DivLayer, Iframe, Width);
     	
     	// get object references to div layer and div_layer that called this function
		var div_layer = if_returnObjRef(DivLayer);
     	var div_layerIframe = if_returnObjRef(Iframe);
     	var div_layer_caller = if_returnObjRef(Caller);
     	 	
         // set default offset for div layer from the caller div
     	var offsetTopDefault; offsetTopDefault = div_layer_caller.offsetHeight + 4;
		          	 	
		// position div layer relative to the opening link  
		var top = if_getAbsoluteOffsetTop(div_layer_caller) + offsetTopDefault;
		var left = if_getAbsoluteOffsetLeft(div_layer_caller); 

		// set position of controls
     	div_layer.style.top = top;
     	div_layer.style.left = left;
     	div_layerIframe.style.top = top;
     	div_layerIframe.style.left = left;
     	   	
       	//  calculate left and top positions of current div layer
     	if (ie4 || ie5 || opera) { 
 			mnu_left = div_layer.style.posLeft;
			mnu_top = div_layer.style.posTop - offsetTopDefault; 
		} else if (ns6) {
			mnu_left = if_removePX(div_layer.style.left);
			mnu_top = if_removePX(div_layer.style.top);
		}
		
		// calculate right and bottom positions of current div layer
		mnu_right = parseInt(mnu_left) + parseInt(mnu_extent.x);			
		mnu_bottom = parseInt(mnu_top) + parseInt(mnu_extent.y);
		
		// now ensure Iframe sits tidy behind Div
		div_layerIframe.style.height = (mnu_bottom - mnu_top);
			    	
		// attempt to keep menu on screen			
		if (ie4 || ie5 || opera || ns6) { 
 			win_width = document.body.clientWidth;
			if (mnu_right > win_width) {
				div_layer.style.left = win_width - Width - 10;
				div_layerIframe.style.left = win_width - Width - 10;
			}
		}
				
		// finally display the menu		
		// if this is not IE we don't need to display the Iframe
		if ((ie4 || ie5 && !opera)) {div_layerIframe.style.display = "";}
		div_layer.style.display = "";
		
}


/* ----------------------------------------------------------- */
// Create div layer to hold menu
/* ----------------------------------------------------------- */

function if_setDiv(InnerHTML, DivLayer, Iframe, mnu_width) {     

	// create iframe to hold div later
    var frameDiv = document.createElement('iframe');     	
    frameDiv.id = Iframe;
    frameDiv.setAttribute('class','');
    frameDiv.setAttribute('src','blank.htm');
    frameDiv.style.position = 'absolute';
    frameDiv.style.zindex = 1;
    frameDiv.style.width = mnu_width;
    
	// create div layer container to holder table
    var elemDiv = document.createElement('div');     	
    elemDiv.id = DivLayer;
    elemDiv.setAttribute('class','');
    elemDiv.style.position = 'absolute';       
    elemDiv.style.zindex = 50;
	elemDiv.style.width = mnu_width;
	  
	// deteremine what table to apply as the innerHTML of the div layer container
	elemDiv.innerHTML = InnerHTML;
	
	// add elements to document
	document.body.appendChild(frameDiv);   
	document.body.appendChild(elemDiv);    
	
	// get layer height now content has been added
	var mnu_height;
	
	if ((ie4 || ie5) || ns6)
		{mnu_height = elemDiv.offsetHeight;}
	else if (ns4)	
		{mnu_height = elemDiv.clip.height;}
	
	mnu_extent = {
		x : mnu_width,
		y : mnu_height
	};
		
	// finally hide the layer 
	frameDiv.style.display = "none";			
	elemDiv.style.display = "none";
		
}

/* ----------------------------------------------------------- */
// Hide all menus on click event of document
/* ----------------------------------------------------------- */

function if_hideAllMenusOnClick(event) {
	
	if (mnu_active) {
		
		// find the element that was clicked on.

		if (ie4 || ie5 || opera) {
			el = window.event.srcElement;
		}
		else {
			el = (event.target.tagName ? event.target : event.target.parentNode);
		}

		// if the element is not part of a menu, reset and clear the active button.
		if (if_getContainer(el, "DIV") == null) {
			if_hideAllMenus();
		}
	
	}
		
}

/* ----------------------------------------------------------- */
// Hide all active menus 
/* ----------------------------------------------------------- */

function if_hideAllMenus() {
	
	if (mnu_active) {	
		for (count = 0; count < mnu_items.length; count++)	{
			var div_layer = if_returnObjRef(mnu_items[count]);
			var iframe_layer = if_returnObjRef(mnu_items[count] + "_Iframe");
			if (div_layer != null && iframe_layer != null)	{
				iframe_layer.style.display = 'none';
				div_layer.style.display = 'none';
				mnu_items[count] = '';
				mnu_active = false;
			}
		}			
	}
		
}

/* ----------------------------------------------------------- */  
// Get top location of menu link to position menu
/* ----------------------------------------------------------- */

function if_getAbsoluteOffsetTop(obj) {

	var top = obj.offsetTop;
	var parent = obj.offsetParent;
	while (parent != document.body) {
	top += parent.offsetTop;
	parent = parent.offsetParent;	}
	return top;
	
}

/* ----------------------------------------------------------- */
// Get left location of menu link to position menu
/* ----------------------------------------------------------- */

function if_getAbsoluteOffsetLeft(obj) {

	var left = obj.offsetLeft;
	var parent = obj.offsetParent;
	while (parent != document.body) {
	left += parent.offsetLeft;
	parent = parent.offsetParent;	}
	return left;
	
}

⌨️ 快捷键说明

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