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

📄 flashwebmenu.js

📁 Flash 菜单 - 各式各样的下拉菜单 - 8种下拉菜单
💻 JS
字号:
/*
================================================================================

	flashwebmenu.js

	Copyright (C) 2000 - 2002 support@secretplus.com

================================================================================
*/
//------------------------------------------------------------------------------

var flashwebmenu=new function(){
	this.c=0;
	this.ver=0;
	this.swf=null;
//------------------------------------------------------------------------------
	var p=new String(navigator.platform);
	var v=new String(navigator.appVersion);
	if(p.indexOf("Win32")>=0){
		var i=v.indexOf("MSIE");
		if(i>=0){
			var j=v.indexOf(";",i);
			this.ver=parseFloat(v.substring(i+5,j));
		}
	}
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
	if(this.ver>=4&&this.swf==null){
		for(i = 0; i < document.all.length; i++){
			if(document.all[i].tagName=="SCRIPT"){
				var src=document.all[i].src;
				var srcLower=src.toLowerCase();
				if(srcLower.indexOf("flashwebmenu.js")>=0){
                                        this.swf=src.substr(0,src.length-2)+"swf";
					break;
				}
			}
		}
	}
//------------------------------------------------------------------------------
	this.events=function(){
		this.ons=window.onscroll;
		window.onscroll=function(){
			if(flashwebmenu.ons!=null)flashwebmenu.ons();
			for(i=0;i<flashwebmenu.c;i++)window["spmenu"+i].spresize();
		}
		this.onr=window.onresize;
		window.onresize=function(){
			if(flashwebmenu.onr!=null)flashwebmenu.onr();
			for(i=0;i<flashwebmenu.c;i++)window["spmenu"+i].spresize();
		}
		this.obp=window.onbeforeprint;
		window.onbeforeprint=function(){
			if(flashwebmenu.obp!=null)flashwebmenu.obp();
			for(i=0;i<flashwebmenu.c;i++)window["spmenu"+i].style.visibility="hidden";
		}
		this.oap=window.onafterprint;
		window.onafterprint=function(){
			if(flashwebmenu.oap!=null)flashwebmenu.oap();
			for(i=0;i<flashwebmenu.c;i++)window["spmenu"+i].style.visibility="visible";
		}
		if(this.ver<5){
			this.onl=window.onload;
			window.onload=function(){
				window.document.body.scrollTop=0;
				if(flashwebmenu.onl!=null)flashwebmenu.onl();
			}
		}
		if(this.ver<5.5){
			this.onover=window.document.body.onmouseover;
			window.document.body.onmouseover=function(){
				if(flashwebmenu.onover!=null)flashwebmenu.onover();
				for(i=0;i<flashwebmenu.c;i++){
					if(event.fromElement!=null&&event.fromElement.id=="spmenu"+i)window["spmenu"+i].onmouseout();
				}
			}
			this.onout=window.document.body.onmouseout;
			window.document.body.onmouseout=function(){
				if(flashwebmenu.onout!=null)flashwebmenu.onout();
				for(i=0;i<flashwebmenu.c;i++){
					if(event.toElement!=null&&event.toElement.id=="spmenu"+i)window["spmenu"+i].onmouseover();
				}
			}
		}
	}
//------------------------------------------------------------------------------
	this.r2url=function(url){
		var u=url.toLowerCase();
		if(u.indexOf("http:")==0 || u.indexOf("https:")==0 || u.indexOf("file:")==0)return url;
		var protocol=window.location.protocol;
		var host=window.location.host;
		var path=window.location.pathname;
		var ret=protocol+"//"+host;
		if(protocol.toLowerCase()=="file:")path=path.replace(/\x5C/g,"/");
		path=path.split("/");
		if(url.indexOf("/")==0)return ret+url;
		if(url.indexOf("./")==0)url=url.substr(2);
		var x=path.length-1;
		var i=0;
		while((i=url.indexOf("../"))>=0){
			x--;
			i+=3;
			url=url.substr(i);
		}
		if(x<=0)x=1;
		path[x++]=url;
		path=path.slice(0,x);
		path=path.join("/");
		return ret+path;
	}
//------------------------------------------------------------------------------
	this.create=function(menuxml,zIndex){
		if(this.ver<4||this.swf==null)return null;
		if(this.c==0)this.events();

		zIndex=parseInt(zIndex);
		if(isNaN(zIndex))zIndex=64;

		var fscstr="<script for='spmenu"+this.c+"' event='FSCommand(command,args)'>flashwebmenu.cm(this.idx,command,args);</script>";
		var divstr="<div id='spmenud"+this.c+"' style='position:relative;width:1;height:1;display:none;'></div>";
		var objstr="<object id='spmenu"+this.c+"' style='position:absolute;left:0;top:0;z-index:"+zIndex+";' width='512' height='288' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'><param name='movie' value='"+this.swf+"'><param name='loop' value='false'><param name='scale' value='exactfit'><param name='wmode' value='transparent'><param name='menu' value='false'></object>";

		document.write(fscstr+divstr+objstr);
		var m=document.all["spmenu"+this.c];
		m.d=document.all["spmenud"+this.c];
		m.d.m=m;
		m.o=0
		m.loaded=0;
		m.ver=this.ver;
		m.old_x=null;
		m.old_y=null;
		m.idx=this.c;
		m.sp=this;
		m.tid=null;
		m.onOver=null;
		m.onActive=null;
		m.active=0;
		m.menuxml=this.r2url(menuxml);


		for(op=m.offsetParent;op!=null;op=op.offsetParent){
			if(op.tagName.toLowerCase()!="body"){
				op.style.zIndex=zIndex;
			}
		}

		m.time=function(x){
			if(x&1==1&&this.tid!=null){
				window.clearTimeout(this.tid);
				this.tid=null;
			}
			if(x&2==2){
				this.tid=window.setTimeout("window['spmenu"+this.idx+"'].tmo()",this.tr);
			}
		}
		m.vset=function(d,v){
			this.SetVariable("_level0."+d,v);
		}
		m.pset=function(d,p,v){
			v=""+v;
			if(d==0)d="_level0";
			else if(d==1)d="_level0.spmenu";
			this.TSetProperty(d,p,v);
		}
//------------------------------------------------------------------------------
		m.spmove=function(){//div li

		var _x=this.d.offsetLeft;
			var _y=this.d.offsetTop;
			if(_x!=this.old_x){
				this.old_x=_x;
				this.pset(1,0,_x);
			}
			if(_y!=this.old_y){
				this.old_y=_y;
				this.pset(1,1,_y);
			}
		}

//------------------------------------------------------------------------------
		m.spresize=function(){
			if(this.loaded==0)return;

			var b=window.document.body;
			if(this.st!=b.scrollTop)this.st=b.scrollTop;
			if(this.sl!=b.scrollLeft)this.sl=b.scrollLeft;
			if(this.cw!=b.clientWidth)this.cw=b.clientWidth;
			else if(this.sh!=b.scrollHeight)this.sh=b.scrollHeight;
			if(this.ch!=b.clientHeight)this.ch=b.clientHeight;
			else if(this.sw!=b.scrollWidth)this.sw=b.scrollWidth;

			this.vset("l",this.sl);
			this.vset("t",this.st);
			this.vset("r",this.cw+this.sl);
			this.vset("b",this.ch+this.st);

			var width=(this.sw>this.cw)?this.sw:this.cw;
			var height=(this.sh>this.ch)?this.sh:this.ch;

			if(this.style.posWidth!=width){
				this.style.posWidth=width;
				this.pset(0,2,51200/width);
			}
			if(this.style.posHeight!=height){
				this.style.posHeight=height;
				this.pset(0,3,28800/height);
			}
			if(this.tp<2){
				var _x=0;
				var _y=0;
				if(this.pz==0){//div li
					_x=this.d.offsetLeft;
					_y=this.d.offsetTop;
				}
				else if(this.pz==1){//screen
					if(this.ha==0)_x=this.sl+this.x;//left
					else if(this.ha==2)_x=this.sl+this.cw-this.w-this.x;//right
					else _x=this.sl+((this.cw-this.w)/2);//center
					if(this.va==1)_y=this.st+this.y;//top
					else if(this.va==3)_y=this.st+this.ch-this.h-this.y;//bottom
					else _y=this.st+((this.ch-this.h)/2);//center
				}
				else if(this.pz==2){//absolute
					if(this.ha==0)_x=this.x;//left
					else if(this.ha==2)_x=width-this.w-this.x;//right
					else _x=(width-this.w)/2;//center
					if(this.va==1)_y=this.y;//top
					else if(this.va==3)_y=height-this.h-this.y;//bottom
					else _y=(height-this.h)/2;//center
				}
				if(_x!=this.old_x){
					this.old_x=_x;
					this.pset(1,0,_x);
				}
				if(_y!=this.old_y){
					this.old_y=_y;
					this.pset(1,1,_y);
				}
			}
		}
//------------------------------------------------------------------------------
		m.onmouseout=function(){
			if(this.tr!=0){
				this.o=0;
				this.time(3);
			}
		}
		m.onmouseover=function(){
			this.o=1;
			this.time(1);
		}
//------------------------------------------------------------------------------
		m.tmo=function(){
			this.tid=null;
			if(this.o==1)return;
                        this.vset("state",1);
			this.active=0;
			if(this.tp>1)m.style.visibility="hidden";
			

		}
//------------------------------------------------------------------------------
		m.show=function(x,y,openedTopLevelMenu_){
			if(this.tp<2)return;
			var openedTopLevelMenu=0;
			if(typeof(openedTopLevelMenu_)=="number")openedTopLevelMenu=openedTopLevelMenu_;

			if((this.tp==2&&openedTopLevelMenu==0)||(this.tp==3&&openedTopLevelMenu>0&&openedTopLevelMenu<this.msc)){
				this.vset("openedTopLevelMenu",openedTopLevelMenu);
				this.time(3);
				if(typeof(x)=="number"&&typeof(y)=="number"){
					if(x<0)x=0;
					if(y<0)y=0;
					var b=window.document.body;
					this.pset(1,0,x+b.scrollLeft);
					this.pset(1,1,y+b.scrollTop);
				}
                                this.vset("state",1);
  				this.style.visibility="visible";
			}
		}
//------------------------------------------------------------------------------
                this.c++;
		return m;
	}
//------------------------------------------------------------------------------
 	this.cm=function(idx,command,args){
		var m=window["spmenu"+idx];
		var c=parseInt(command);
		if(c==0){
                	
                        if(m.onOver!=null)m.onOver();
			if(m.active==0){
				m.active=1;
				if(m.onActive!=null)m.onActive();
			}
		}
		else if(c==1){
			args=args.split(",");
                       	var d=["tr","tp","pz","ha","va","x","y","w","h","msc"];
                       	for(var i=0;i<args.length;i++)m[d[i]]=args[i];
			if(m.tp==2){
				this.popup=m;
				document.oncontextmenu=function(){
					flashwebmenu.popup.show(event.clientX,event.clientY);
					return false;
				}
			}
        		if(m.tp<2&&m.pz==0){
                                m.d.style.display="inline";
				m.d.style.posWidth=m.w;
				m.d.style.posHeight=m.h;
                                if(m.ver<5.5)setInterval("window.spmenu"+idx+".spmove();",10);
                                m.d.onmove=function(){
					this.m.spmove();
				}
			}
			m.style.visibility="hidden";
			m.pset(1,7,1);//visible
			m.loaded=1;
			m.sh=window.document.body.scrollHeight;
			m.sw=window.document.body.scrollWidth;
			m.spresize();
			if(m.tp<2)m.style.visibility="visible";
                        
		}
		else if(c==2){
			m.vset("menuxml",m.menuxml);
		}
	}
//------------------------------------------------------------------------------
}
//------------------------------------------------------------------------------

⌨️ 快捷键说明

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