/********************************************************************************
Move items up
********************************************************************************/
createSlideMenu.prototype.moveUp = function(top,num,y){
var move = 0, m, yy=0;
if(this.active[0]>-1 && top>-1){
m = this.menus[top]
if(m.o.y>y){
if((m.o.y-this.pxspeed)<y) yy = -(((m.o.y-y)))
else yy=-this.pxspeed; this.moveItems(yy,top)
move=1
}
}
if(move) setTimeout(this.name+".moveUp("+top+","+num+","+y+")",this.timspeed)
else{
m = this.menus[num] 
for(var i=m.lev;i<this.active.length;i++){ //Reset images - actives et cetera
if(this.active[i]>-1){
temp = this.menus[this.active[i]]
temp.o.moveIt(temp.o.x-this.inset,temp.o.y)
if(this.useImages) temp.o.bgImg(temp.img)  //Change bg
if(this.arrow) temp.ar.replaceChild(document.createTextNode("4"),temp.ar.childNodes[0])
ch = temp.childs
for(var j=0;j<ch.length;j++){
ch[j].o.hideIt(); ch[j].o.movey(ch[j].origy)
}
this.active[i] = -1
}
}
//Then open the current one, if childs
if(m.childs.length == 0){this.going = 0; return}
for(i=0;i<m.childs.length;i++){ //Show all
m.childs[i].o.showIt()
y = m.childs[i].o.y + m.childs[i].o.h
}
y+=this.l[m.lev].between
if(m.lev>0 && m.chnum!=this.menus[m.parent].childs.length-1){
yy=y; y = this.menus[m.parent].endy + this.l[m.lev].between
}
m.o.moveIt(m.o.x+this.inset,m.o.y)  //Inset current item:
if(this.useImages) m.o.bgImg(this.l[m.lev].roundImg)  //Change bg
this.active[m.lev] = num //Set active
if(this.arrow) m.ar.replaceChild(document.createTextNode("6"),m.ar.childNodes[0])
if(m.nexttop>-1 || m.nextel>-1) this.moveDown(m.nexttop,m.nextel,y,yy) //Then start moving all other elements down
else this.going=0
}
}
/********************************************************************************
Move items down
********************************************************************************/
createSlideMenu.prototype.moveDown = function(top,num,y,yyy){
var m = this.menus[top],yy
if(m && m.o.y<y){
if((m.o.y+this.pxspeed)>y) yy = y-m.o.y
else yy=this.pxspeed
this.moveItems(yy,top)
setTimeout(this.name+".moveDown("+top+","+num+","+y+","+yyy+")",this.timspeed)
}else if(num>-1){
this.moveDown(num,-1,yyy,0)
}else this.going=0
}
/********************************************************************************
Slide menu object
********************************************************************************/
function createSlideMenu(name){
document.write('<div id="'+name+'cont">') //The cont div start
this.name = name
this.menus = new Array()
this.curr = 0
this.lasttype = new Array()
this.writesubsonly = 0
this.level = new Array()
this.l = new Array()
this.topmenus = new Array()
this.active = new Array()
return this
}
/********************************************************************************
Function to create the objects and the divs
********************************************************************************/
createSlideMenu.prototype.makeMenu = function(type,text,lnk,target,end){
var str="",tg="",parent,m,cl
m = this.menus[this.curr] = new Object()
this.lasttype[type] = this.curr; if(!lnk) lnk="#"
m.lev = 0; m.type = type; m.childs = new Array()
m.num = this.curr; m.parent = -1; m.nextel = -1
m.nexttop = -1; parent = 0
//DEBUGGING::::::
m.text = text

if(type.indexOf("sub")>-1){  //Find parent type
if(type.length == 3){ //sub
parent = "top"; m.lev = 1
}else{
parent = type.substr(3,1) //sub2+
m.lev = parent; parent--
if(parent==1){
parent = "sub"; m.lev = 2
}else parent = "sub"+parent
}
}
  if(m.lev>=this.l.length){//Level control (same as CM4)
    var p1,p2=0; 
if(m.lev>=this.level.length) p1=this.l[this.level.length-1];
    else p1=this.level[m.lev]; 
this.l[m.lev]=new Array(); 
if(!p2) p2=this.l[m.lev-1]
    if(m.lev!=0 && p1){ 
      for(i in p1){ //Copying an entire object
if(p1[i]==null) this.l[m.lev][i]=p2[i]; 
else this.l[m.lev][i]=p1[i]
}
    }else{
this.l[m.lev]=this.level[0]; 
}
    this.level[m.lev]=p1=p2=null 
  } 
this.active[m.lev] = -1
if(parent){ //Find parent element
m.parent = this.lasttype[parent]
parent = this.menus[this.lasttype[parent]]
parent.childs[parent.childs.length] = m
if(this.arrow && parent.childs.length==1){str='<span class="'+this.arrow+'">4</span>'
if(document.getElementById && document.getElementById(parent.id).childNodes){
parent.ar = document.getElementById(parent.id).childNodes[this.useImage?1:0].childNodes[0]
parent.ar.innerHTML = str+parent.ar.innerHTML; parent.ar=parent.ar.childNodes[0]} else this.arrow=""
}
}else this.topmenus[this.topmenus.length] = this.curr
if(!this.writesubsonly || type!="top"){
cl = this.l[m.lev].className
m.id = id = this.name + "_" + this.curr
str= '<div id="'+id+'" class="'+cl+'">' //main div start
if(this.useImages){
str+='<div class="'+this.bgClass+'">'//bgdiv
str+='<img id="'+id+'_img" src="'+this.l[m.lev].regImage+'" />' 
str+='</div>' //bgdiv
}
if(target) tg =' target="'+target+'" '
str+='<div class="'+this.txtClass+'"><a href="'+lnk+'" '+tg+' onclick="'+this.name+'.switchMenu('+this.curr+'); if(document.getElementById) this.blur(); '
    if(lnk=="#") str+='return false'
    str+='" class="'+this.l[m.lev].classNameA+'">?+text+'</a><br /></div>\n'
str+="</div>\n\n" //main div end
document.write(str)
}
this.curr++
}

解决方案 »

  1.   

    /********************************************************************************
    Level object
    ********************************************************************************/
    function slideMenu_makeLevel(){
      var c=this, a=arguments; 
    c.left=a[0]||0; c.width=a[1]||null; c.height=a[2]||null;
    c.between=a[3]||null; c.className=a[4]||null; c.classNameA=a[5]||null;
    c.regImage=a[6]||null; c.roundImg=a[7]||null; c.roundImg2=a[8]||null; 
    c.subImg=a[9]||null; c.subRound=a[10]||null; return c
    }
    /********************************************************************************
    Preloading images
    ********************************************************************************/
    function preLoadBackgrounds(){
      for(i=0;i<arguments.length;i++){
        this[i]=new Image()
        this[i].src=arguments[i]
      }
      return this
    }
    </SCRIPT><META content="MSHTML 5.00.2614.3500" name=GENERATOR></HEAD>
    <BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginwidth="0" marginheight="0">
    <SCRIPT>
    slideMenu = new createSlideMenu("slideMenu")//Variables to set:
    slideMenu.menuy=1 //The top placement of the menu.
    slideMenu.menux=1 //The left placement of the menu
    slideMenu.useImages = 0 //Are you using images or not?
    slideMenu.pxspeed=16 //The pixel speed of the animation
    slideMenu.timspeed=25 //The timer speed of the animation
    slideMenu.inset =0 //How much the selected elements should pop to the left
    slideMenu.arrow="clArrow"//Needed dummy classes
    slideMenu.bgClass = "slideMenuBG"
    slideMenu.txtClass = "slideMenuText"//Level properties - ALL properties have to be spesified in level 0
    //This works the same way as the CM4 script (if you have seen it)
    slideMenu.level[0] = new slideMenu_makeLevel(
    left = 0,
    width = 185,
    height = 20,
    between = 2,
    className = "clSlideMenu0",
    classNameA = "clA0",
    regImage = "",
    roundImg = "",
    roundImg2 = "",
    subImg = "",
    subRound= "")

    slideMenu.level[1] = new slideMenu_makeLevel(10,160,20,2,"clSlideMenu1","clA1","level1_regular.gif","level1_round2.gif","level1_round.gif","level1_sub.gif", "level1_sub_round.gif")//Image preload --- leave this
    for(var i=0;i<slideMenu.level;i++){
    var l = slideMenu.level[i]
    new preLoadBackgrounds(l.regImage,l.roundImg,l.roundImg2,l.subImg,l.subRound)
    }slideMenu.makeMenu('top','News')
    slideMenu.makeMenu('sub',' Top Stories','news/news_items/topstories.html','main')
    slideMenu.makeMenu('sub',' Business News','news/news_items/topbusiness.html','main')
    slideMenu.makeMenu('sub',' Finance News','news/news_items/finance.html','main')
    slideMenu.makeMenu('sub',' International Relations','news/news_items/internationalrelations.html','main')
    slideMenu.makeMenu('sub',' Mergers & Acquisitions','news/finance_items/mergers.html','main')
    slideMenu.makeMenu('sub',' Science News','news/science_items/science.html','main')
    slideMenu.makeMenu('sub',' Stock Watch','news/finance_items/stocks.html','main')
    slideMenu.makeMenu('sub',' MORE NEWS','news/index.html','main')slideMenu.makeMenu('top','PPE WEB')
    slideMenu.makeMenu('sub',' Home Page','http://www.ppeweb.com','_blank')
    slideMenu.makeMenu('sub',' Latest Articles in Brief','ppeweblatest.php','main')
    slideMenu.makeMenu('sub',' Politics Articles','http://ppeweb.com/modules.php?op=modload&name=News&file=index&catid=&topic=8','_blank')
    slideMenu.makeMenu('sub',' Philosophy Articles','http://ppeweb.com/modules.php?op=modload&name=News&file=index&catid=&topic=9','_blank')
    slideMenu.makeMenu('sub',' Economics Articles','http://ppeweb.com/modules.php?op=modload&name=News&file=index&catid=&topic=10','_blank')
    slideMenu.makeMenu('sub',' Search for Articles','http://ppeweb.com/modules.php?op=modload&name=Search&file=index','_blank')

    slideMenu.makeMenu('top','Sport')
    slideMenu.makeMenu('sub',' Top Stories','sport/sport_items/sport_topstories.html','main')
    slideMenu.makeMenu('sub',' Football','sport/sport_items/sport_football.html','main')
    slideMenu.makeMenu('sub',' Cricket','sport/sport_items/sport_cricket.html','main')
    slideMenu.makeMenu('sub',' Motor Sports','sport/sport_items/sport_motorsports.html','main')
    slideMenu.makeMenu('sub',' Tennis','sport/sport_items/sport_tennis.html','main')
    slideMenu.makeMenu('sub',' Rugby','sport/sport_items/sport_rugby.html','main')
    slideMenu.makeMenu('sub',' MORE SPORT','sport/index.html','main')slideMenu.makeMenu('top','Entertainment')
    slideMenu.makeMenu('sub',' General News','entertainment/entertainment_items/entertainment_generalnews.html','main')
    slideMenu.makeMenu('sub',' Arts & Culture News','entertainment/entertainment_items/entertainment_artsetculture.html','main')
    slideMenu.makeMenu('sub',' MP3 News','entertainment/entertainment_items/entertainment_mp3.html','main')
    slideMenu.makeMenu('sub',' Movie Database','http://e-consort.subportal.com/cgi-bin/apollo/apollo.cgi','main')
    slideMenu.makeMenu('sub',' Jokes','http://e-consort.subportal.com/jokes/','main')slideMenu.makeMenu('top','Services')
    slideMenu.makeMenu('sub',' Email','services/email/index.html','main')
    slideMenu.makeMenu('sub',' Web Communities','http://webcom.e-consort.co.uk/cgi-bin/manager.cgi','main')
    slideMenu.makeMenu('sub',' Web Hosting','http://hosting.e-consort.co.uk','_blank')
    slideMenu.makeMenu('sub',' Support Site','http://support.e-consort.co.uk','_blank')
    slideMenu.makeMenu('sub',' Billing Site','http://billing.e-consort.co.uk','_blank')
    slideMenu.makeMenu('sub',' Report Abuse','http://abuse.e-consort.co.uk','_blank')

    slideMenu.init()
    slideMenu.switchMenu(0)
    </SCRIPT>
    = </BODY></HTML>