Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling file.js twice ??? 1

Status
Not open for further replies.

pookie62

Technical User
Oct 22, 2004
139
GB
Hi,
I'm calling a menu script like this:
Code:
<script language="JavaScript" src="slidemenu.js" type="text/javascript">

The page is php and has an included header in which another menu is called like this:
Code:
<SCRIPT tyle="text/javascript">
var iecheck=document.all&&document.getElementById
if (iecheck){
document.write('<script type="text/javascript" src="../menu/mymenu.js"><\/script>')
}
</SCRIPT>

The SlideMenu is working fine, but the second menu (rightclick on the page and menu pops up) is not working.
Is there a way around this ???
Thanks for supporting !
 
It's probably a case of the onload event handler in one script is overriding the onload event handler in the other. You'll need to ensure than any onload event handler takes into account other onload event handlers, calling then in the right order, or make sure than you only have one onload event handler, which calls all the relevant code for both scripts.

Without seeing both scripts, it would be futile to comment further.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi BillyRay,
Thanks for your reply, let me show you the both scripts cause I'm no good with these scripts..
This is the so called header which is included in the trouble giving php page

Code:
<HTML>
<HEAD>
<TITLE>Actionshooting Nederland</TITLE>
<LINK HREF="../menu/mymenu.css" type="text/css" REL="stylesheet">
<SCRIPT tyle="text/javascript">
var iecheck=document.all&&document.getElementById
if (iecheck){
document.write('<script type="text/javascript" src="../menu/mymenu.js"><\/script>')
}
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
// Use the following three variables 
// to set up the message:
var msg = "Klik met rechtermuisknop op pagina voor menu.."
var delay = 50
var startPos = 75
// Don't touch these variables:
var timerID = null
var timerRunning = false
var pos = 0
// Crank it up!
StartScrolling()
function StartScrolling(){
    // Make sure the clock is stopped
    StopTheClock()
    // Pad the message with spaces to 
    // get the "start" position
    for (var i = 0; i < startPos; i++) 
        msg = " " + msg
    // Off we go...
    DoTheScroll()
}
function StopTheClock(){
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}
function DoTheScroll(){
    if (pos < msg.length)
        self.status = msg.substring(pos, msg.length);
    else
        pos=-1;
    ++pos
    timerRunning = true
    timerID = self.setTimeout("DoTheScroll()", delay)
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="javascript">
if (iecheck){
createMenus();
document.oncontextmenu=function(){
showMenu(event);
return false;
}
document.onmouseup=function(){
hideMenu(event);
return false;
}
}
</SCRIPT>
</BODY>
</HTML>

mymenu.js:
Code:
// Menu script created by Kari Hollo, Finland
// Use these files "as is". You may modify them freely.
// If you can't get them work after modificatins, I don't care...
// Wrote and tested with MS IE6 only...
// Modified by JavaScript Kit ([URL unfurl="true"]http://www.javascriptkit.com)[/URL]
// constants ********

//default/required menu images:
var myi=new Image; myi.src="../menu/icons/arrow__r.gif";		//submenu arrow
var myiw=new Image; myiw.src="..menu/icons/arrow__rw.gif";		//same as white
var myie=new Image; myie.src="../menu/icons/arrow__e.gif";		//empty pic
var myis=new Image; myis.src="../menu/icons/spacer.gif";		//spacer
var myisb=new Image; myisb.src="../menu/icons/spacer__b.gif";	//enpty end pic left to spacer


var kto=2000;	//killTimeout [ms]
var mymenuwidth="150px"     //menu width				
var bg_color="#D6D6D6";	    //colors...
var bg_color_hl="navy";	    //syncronize with css file!!
var fg_color="black";
var fg_color_hl="white";
var spc="#SPACER#";	//spaser sign
var arr="#ARROW#";	//submenu sign


// caption/spacer,icon,gimmick/submenu
// MAIN MENU, DO NOT REMOVE, EDIT ONLY *********	
var m1=new Array;
m1[0]=new Array("");
m1[1]=new Array("Home","../menu/icons/ico_gun01.gif","goto('[URL unfurl="true"]http://www.actionshooting.nl')");[/URL]
m1[2]=new Array(spc); //add divider
m1[3]=new Array("Nieuws","../menu/icons/pelle.gif","goto('../info/nieuws.php')");
m1[4]=new Array("Info"+arr,"../menu/icons/pelle.gif",11); //denote sub menu (using "arr")
m1[5]=new Array("Links","../menu/icons/pelle.gif","goto('../info/clublinks.php')");
m1[6]=new Array("Wedstrijd-info"+arr,"../menu/icons/pelle.gif",12);
m1[7]=new Array("Competitie"+arr,"../menu/icons/pelle.gif",13);
m1[8]=new Array("Agenda"+arr,"../menu/icons/pelle.gif",21);
m1[9]=new Array("Jouw account","../menu/icons/pelle.gif","goto('../Loginsys/main.php')");

// name submenus reasonable!
// m1## 1.level, m2## 2.level and so on...

// 1ST SUB MENU
var m11=new Array;	
m11[0]=new Array("");
m11[1]=new Array("ASN Forum","../menu/icons/pelle.gif","goto('[URL unfurl="true"]http://www.actionshooting.nl/phpbb2/')");[/URL]
m11[2]=new Array("ASN Folder","../menu/icons/pelle.gif","goto('../info/folder.php')");
m11[3]=new Array("Regelement","../menu/icons/pelle.gif","goto('../info/reglem.php')");
m11[4]=new Array("Handl. Baancomm","../menu/icons/pelle.gif","goto('../info/hl-bc.php')");
m11[5]=new Array("Het Bestuur","../menu/icons/pelle.gif","goto('../info/bestuur.php')");
m11[6]=new Array("Feedback","../menu/icons/pelle.gif","goto('../Forms/feedback.php')");
m11[7]=new Array("Inschrijven","../menu/icons/pelle.gif","goto('../Forms/ASNForm.php')");

// 2ND SUB MENU
var m12=new Array;	
m12[0]=new Array("");
m12[1]=new Array("Uitslagen 2006","../menu/icons/pelle.gif","goto('../wedstrijd/2006/Wedstrijduitslag.php')");
m12[2]=new Array("Uitslagen 2005","../menu/icons/pelle.gif","goto('../wedstrijd/2005/Wedstrijduitslag.php')");
m12[3]=new Array("Wedstrijd opgeven","../menu/icons/pelle.gif","goto('../Forms/WedstrijdForm.php')");
m12[4]=new Array("ASN Score","../menu/icons/pelle.gif","goto('../files/asnscore/login.php')");

// 3ND SUB MENU
var m13=new Array;	
m13[0]=new Array("");
m13[1]=new Array("Info","../menu/icons/pelle.gif","goto('../comp/compinfo.php')");
m13[2]=new Array("Competitiestanden","../menu/icons/pelle.gif","goto('../comp/Klassmenu/compmenu.php')");
m13[3]=new Array("Competitiestand 2005","../menu/icons/pelle.gif","goto('../comp/2005/Klassmenu/compmenu.php')");


// 1ST SUB SUB MENU
var m21=new Array;
m21[0]=new Array("");
m21[1]=new Array("Januari","../menu/icons/pelle.gif","goto('../agenda/agenda.php#januari')");
m21[2]=new Array("Februari","../menu/icons/pelle.gif","goto('../agenda/agenda.php#februari')");
m21[3]=new Array("Maart","../menu/icons/pelle.gif","goto('../agenda/agenda.php#maart')");
m21[4]=new Array("April","../menu/icons/pelle.gif","goto('../agenda/agenda.php#april')");
m21[5]=new Array("Mei","../menu/icons/pelle.gif","goto('../agenda/agenda.php#mei')");
m21[6]=new Array("Juni","../menu/icons/pelle.gif","goto('../agenda/agenda.php#juni')");
m21[7]=new Array("Juli","../menu/icons/pelle.gif","goto('../agenda/agenda.php#juli')");
m21[8]=new Array("Augustus","../menu/icons/pelle.gif","goto('../agenda/agenda.php#augustus')");
m21[9]=new Array("September","../menu/icons/pelle.gif","goto('../agenda/agenda.php#september')");
m21[10]=new Array("Oktober","../menu/icons/pelle.gif","goto('../agenda/agenda.php#oktober')");
m21[11]=new Array("November","../menu/icons/pelle.gif","goto('../agenda/agenda.php#november')");
m21[12]=new Array("December","../menu/icons/pelle.gif","goto('../agenda/agenda.php#december')");


//ENTER MENU IDs of above. UPDATE IF ADD/REMOVE MENUS!
var mvect=new Array(1,11,12,13,21);			


// END OF EDITTING. variables ********
var th;							//menu height
var tw;							//menu width
var vas=0;						//on left flag
var llv=false;						//menu visible flag
var tid;						//timeout id
var ksm=0;						//known sub sub menu id


//************** FUNCTIONS
//******** base function to create menus

// error handler ***************
function stoperror(){
	return true;
}
window.onerror=stoperror;  //suppress potential JS errors. Comment line if you need to debug page.

function createMenus(){
	for(xyzzy=0;xyzzy<mvect.length;xyzzy++){
		document.write("<DIV id='teva"+mvect[xyzzy]+"' class='men'>");
		document.write("<TABLE WIDTH='100%' BORDER=0 CELLSPACING=0 CELLPADDING=0>");
		initMenu(mvect[xyzzy]);
		document.write("</TABLE></DIV>");
	}
}

//******** initialization
function initMenu(t){
var obj=eval("teva"+t);	//container
var vect=eval("m"+t);	//menu
var ve1;				//caption
var ve2;				//picture
var ve3;				//trick/no of submenu 
var spacers=0;			//spacer counter
	obj.style.height=(vect.length-1)*16+"px";
	obj.style.width=mymenuwidth;
	if(t==1){
		th=obj.style.height.substr(0,obj.style.height.length-2);
		tw=obj.style.width.substr(0,obj.style.width.length-2);
	}
	for(i=1;i<vect.length;i++){
		ve1=eval("vect["+i+"][0]");
		document.write("<TR>");
		if(ve1==spc){
			spacers++;
			document.write("<TD colspan=3 style='height:8px;'>"+
				"<img src='"+myisb.src+"' style='width:3px;height:2px;'>"+
				"<img src='"+myis.src+"' style='width:95%;height:2px;'></TD>");
		}else{ 
			ve2=eval("vect["+i+"][1]");
			ve3=eval("vect["+i+"][2]");
			if(ve1.match(arr)){
				var oy=16*(i-1)-spacers*8;
				document.write("<TD class='imgtd' style='border:1px solid "+bg_color+";' "+
					"id='m_"+t+"_"+i+"a' onmouseover='act_td("+t+","+i+");showSubMenu("+t+","+ve3+","+oy+");' "+
					"onmouseout='nonact_td("+t+","+i+");'>"+
					"<img id='m_"+t+"_"+i+"ap' src='"+ve2+"' class='icondimensions'></TD>");
				document.write("<TD onmouseover='act_td("+t+","+i+");showSubMenu("+t+","+ve3+","+oy+");' "+
					"onmouseout='nonact_td("+t+","+i+");' class='tdmenu' "+
					"id='m_"+t+"_"+i+"'>&nbsp;"+ve1.substr(0,ve1.length-7)+"</TD>");
				document.write("<td class='imgtd' id='m_"+t+"_"+i+"b' "+
					"onmouseover='act_td("+t+","+i+");showSubMenu("+t+","+ve3+","+oy+");' "+
					"onmouseout='nonact_td("+t+","+i+");'>"+
					"<img class='arr' id='m_"+t+"_"+i+"bp' src='"+myi.src+"'></td>");
			}else{
				document.write("<TD class='imgtd' style='border:1px solid "+bg_color+";' "+
					"id='m_"+t+"_"+i+"a' onmouseover='act_td("+t+","+i+");' "+
					"onmouseout='nonact_td("+t+","+i+");' "+
					"onclick='eval(m"+t+"["+i+"][2]);'>"+
					"<img id='m_"+t+"_"+i+"ap' src='"+ve2+"' class='icondimensions'></TD>");
				document.write("<TD onmouseover='act_td("+t+","+i+");'	"+
					"onmouseout='nonact_td("+t+","+i+");' onclick='eval(m"+t+"["+i+"][2]);' "+
					"class='tdmenu' id='m_"+t+"_"+i+"'>&nbsp;"+ve1+"</TD>");
				document.write(	"<td class='imgtd' id='m_"+t+"_"+i+"b' "+
					"onmouseover='act_td("+t+","+i+");' "+
					"onmouseout='nonact_td("+t+","+i+");' "+
					"onclick='eval(m"+t+"["+i+"][2]);'>"+
					"<img class='emp' id='m_"+t+"_"+i+"bp' src='' width='12px' height='12px'></td>");
			}
		}
		document.write("</TR>");
	}
	if(t==1){
		obj.style.height=(vect.length-1)*16-spacers*8+"px";
		th=obj.style.height.substr(0,obj.style.height.length-2);
	}
}
// on hover **********
function act_td(t,i){



	window.clearTimeout(tid);
var obj=eval("m_"+t+"_"+i);
	if(t==1) 
		hideSubMenu();
	else
		hideKnownSubMenu(t);
	obj.style.backgroundColor=bg_color_hl;
	obj.style.color=fg_color_hl;
	act1_td(eval(obj.id+"a")); //send cell id

	act2_td(eval(obj.id+"b"));
}
// on mouse out *********
function nonact_td(t,i){
var obj=eval("m_"+t+"_"+i);
	obj.style.backgroundColor=bg_color;
	obj.style.color=fg_color;
	nonact1_td(eval(obj.id+"a"));
	nonact2_td(eval(obj.id+"b"));
	tid=setTimeout('showMenu("mousedown")',kto);
}
//******** left=icon cell hover...
function act1_td(t){
var cel=eval(t);
var pix=eval(t.id+"p");
	if(pix.src!=myie.src)
		cel.style.border='1px outset';
	else{
		cel.style.border="1px solid "+bg_color_hl;
		cel.style.backgroundColor=bg_color_hl;
	}
}
// icon cell on mouse out *********
function nonact1_td(t){
var cel=eval(t);
var pix=eval(t.id+"p");
	if(pix.src!=myie.src)
		cel.style.border="1px solid "+bg_color;
	else{
		cel.style.border="1px solid "+bg_color;
		cel.style.backgroundColor=bg_color;
	}
}
//******** right cell for submenu arrow on hover
function act2_td(t){
var cel=eval(t);
var pix=eval(t.id+"p");
	cel.style.backgroundColor=bg_color_hl;
	if(cel.className!="emp") pix.src=myiw.src;
}
//********** same onmouseout........
function nonact2_td(t){
var cel=eval(t);
var pix=eval(t.id+"p");
	cel.style.backgroundColor=bg_color;
	cel.style.color=fg_color;
	if(cel.className!="emp") pix.src=myi.src;
}
// needs explanations?
function showMenu(e){
	if(llv==true)
		hideMenu();
	else{
		clearTimeout(tid);
		var ah=document.body.clientHeight-th;
		var aw=document.body.clientWidth-tw;

		if(e.clientY < ah) teva1.style.top=e.clientY;
		else teva1.style.top=e.clientY-th;

		if(e.clientX < aw) {teva1.style.left=e.clientX;vas=0;}
		else {teva1.style.left=e.clientX-tw;vas=1;}
		
		teva1.style.visibility='visible';
		llv=true;
		tid=window.setTimeout("hideMenu()",kto);
	}
}
// ...........
function showSubMenu(c,t,y){
		clearTimeout(tid);
var tobj=eval("teva"+c);
var obj=eval("teva"+t);
var ox=tobj.style.left.substr(0,tobj.style.left.length-2); 
var oy=tobj.style.top.substr(0,tobj.style.top.length-2); 
var oh=obj.style.height.substr(0,obj.style.height.length-2);
var ow=obj.style.width.substr(0,obj.style.width.length-2);
	if(vas==0){
		if(Math.round(ox) > Math.round(document.body.clientWidth)-Math.round(ow)*2-10)
			obj.style.left=Math.round(ox)-Math.round(ow)+2;
		else
			obj.style.left=Math.round(ox)+Math.round(ow)-5;
	}else
		obj.style.left=Math.round(ox)-Math.round(ow)+2;
	if(Math.round(oy)+Math.round(y) < Math.round(document.body.clientHeight)-Math.round(oh))
		obj.style.top=Math.round(oy)+Math.round(y);
	else
		obj.style.top=Math.round(oy)+Math.round(y)-Math.round(oh);
	obj.style.visibility='visible';
	ksm=t;
}
//...............
function hideMenu(){
	clearTimeout(tid);
	teva1.style.visibility='hidden';
	hideSubMenu();
	llv=false;
}
//.................
function hideSubMenu(){
var obj;
	for(j=1;j<mvect.length;j++){
		obj=eval("teva"+mvect[j]);
		obj.style.visibility='hidden';
	}
}
//.................
function hideKnownSubMenu(t){
	if(ksm>0 && ksm!=t){
var obj;
		for(j=1;j<mvect.length;j++){
			if(mvect[j]>t){
				obj=eval("teva"+mvect[j]);
				obj.style.visibility='hidden';
			}
		}
		ksm=0;
	}
}

function goto(url){
window.location=url
}

//...............

Slidemenu.js (is working on the page

Code:
/**********************************************************************************
SlideMenu 2.0
*   Copyright (C) 2002 Thomas Brattli
*   This script was released at DHTMLCentral.com
*   Visit for more great scripts!
*   This may be used and changed freely as long as this msg is intact!
*   We will also appreciate any links you could give us.
*
*   Made by Thomas Brattli
*
*Script date: 08/20/2002 (keep this date to check versions)

** Feel free to remove all comments in this file (and the HTML file)
** as long the copyright message is intact to make the files smaller.
*********************************************************************************/

/************************************************************************************
Making cross-browser objects
************************************************************************************/
function makeMenuObj(obj,nest){
	nest=(!nest) ? "":'document.'+nest+'.'
	this.evnt = document.getElementById?document.getElementById(obj):document.all?document.all[obj]:document.layers?eval(nest+'document.'+obj):0;	
	this.css = this.evnt.style?this.evnt.style:this.evnt;										
	this.ref=document.layers?this.evnt.document:document;		
	this.x=this.css.left||this.evnt.offsetLeft;
	this.y=this.css.top||this.evnt.offsetTop;		
	this.hideIt=b_hideIt; this.showIt=b_showIt; this.movey=b_movey
	this.moveIt=b_moveIt; this.moveBy=b_moveBy; this.status=0; 
	this.bgImg=b_bgImg;	this.obj = obj + "Object"; eval(this.obj + "=this"); 
	this.clipTo=b_clipTo;
	return this
}
function b_showIt(){this.css.visibility="visible"; this.status=1}
function b_hideIt(){this.css.visibility="hidden"; this.status=0}
function b_movey(y){this.y=y; this.css.top=this.y}	
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x;this.css.top=this.y}
function b_moveBy(x,y){this.x=this.x+x; this.y=this.y+y; this.css.left=this.x;this.css.top=this.y}
function b_bgImg(img){
	if(document.getElementById) document.getElementById(this.id+"_img").src = img
	else if(document.layers) this.ref.layers[0].document.images[0].src = img
	else document.images[this.id+"_img"].src = img
}
function b_clipTo(t,r,b,l,w){if(document.layers){this.css.clip.top=t;this.css.clip.right=r
this.css.clip.bottom=b;this.css.clip.left=l
}else{this.css.clip="rect("+t+"px,"+r+"px,"+b+"px,"+l+"px)"; if(w){this.css.pixelWidth=this.css.width=r; this.css.pixelHeight=this.css.height=b}}}
/********************************************************************************
Initiating page, making objects..
********************************************************************************/
createSlideMenu.prototype.init = function(){
	document.write("</div>")
	this.cont=new makeMenuObj(this.name+'cont')
	this.cont.moveIt(this.menux,this.menuy)
	var yy = 0, el 	//Make top menus
	for(var j=0;j<this.topmenus.length;j++){
		el = this.menus[this.topmenus[j]]
		el.o = new makeMenuObj(this.name+"_"+el.num,this.name+"cont")
		el.o.moveIt(this.l[0].left,yy); el.top = j; el.origy = yy
		el.o.id = el.id; el.o.status=1; 
		el.o.h = this.l[0].height; el.img = this.l[0].regImage
		yy+=el.o.h + this.l[0].between; el.o.clipTo(0,this.l[0].width,el.o.h,0,1)
		if(j!=this.topmenus.length-1)	el.nexttop = this.topmenus[el.top+1] 
		this.loop(el.num,j)
	}
	this.cont.showIt(); this.cont = null; this.level = null;
}
createSlideMenu.prototype.loop = function(num,j){
	var el = this.menus[num],temp,p,h,w,y,img
	for(var i=0;i<el.childs.length;i++){
		temp = el.childs[i]
		w = this.l[temp.lev].width; h = this.l[temp.lev].height
		y = el.o.y+el.o.h + h*i + this.l[temp.lev].between*i + this.l[temp.lev].between
		temp.o = new makeMenuObj(this.name+"_"+temp.num,this.name+"cont")
		temp.o.hideIt(); temp.o.clipTo(0,w,h,0,1)
		temp.o.moveIt(this.l[temp.lev].left,y)
		el.endy =y+h; temp.origy = y
		temp.o.zIndex=temp.num
		temp.o.h = h; temp.top = j 
		temp.chnum = i; temp.o.id = temp.id 		
		if(this.useImages){ //Setting bgimage
			img=""
			if(temp.childs.length>0){ //With subs
				if(i==el.childs.length-1) img=this.l[temp.lev].subRound
				else img=this.l[temp.lev].subImg
			}else	if(i==el.childs.length-1){
				img=this.l[temp.lev].roundImg2
			}
			if(img){
				temp.o.bgImg(img); temp.img = img
			}else temp.img = this.l[temp.lev].regImage
		}
		p = this.menus[temp.parent] //Setting the next elements
		if(temp.chnum != p.childs.length-1){ //Not the last el
			temp.nextel = p.childs[temp.chnum+1].num
			temp.nexttop = temp.lev==1?p.nexttop:p.nextel
		}else{ //Last el, so we only have nexttop
			temp.nexttop = p.nextel
			if(temp.nexttop==-1) temp.nexttop = p.nexttop
		}
		if(temp.childs.length>0){
			this.loop(temp.num,j) //Recursive call
		}	
	}
}

/********************************************************************************
Moving all objects in the array after a provided array number
********************************************************************************/
createSlideMenu.prototype.moveItems = function(px,num){
	for(i=num;i<this.menus.length;i++){
		if(this.menus[i].o.status){ //Moving all visible menus
			this.menus[i].o.movey(this.menus[i].o.y+px)
		}
	}	
}
/********************************************************************************
Switch menu function.
********************************************************************************/
createSlideMenu.prototype.switchMenu = function(num){	
	if(this.going) return
	var m = this.menus[num]
	if(m.childs.length==0) return
	this.going = 1
	var y=m.o.y+ m.o.h +this.l[m.lev].between
	var clnum = m.num, olev = m.lev, onext = m.nextel
	if(this.active[0]>-1){
		var n = -1
		if(m.lev>0){
			if(this.active[m.lev]>-1) n=this.active[m.lev]
			else n=this.active[m.lev-1]
		}else n = this.active[0]
		m = this.menus[n]
		if(m.lev == 0 && olev==0) y = m.nexttop!=-1?this.menus[m.nexttop].origy:-1
		else if(clnum!=m.num){
			var ny = m.o.y + m.o.h + this.l[m.lev].between
			if(clnum>m.num && olev==m.lev) y = Math.min(ny,y)
			else	if(onext==m.num) y = Math.max(ny,y)
		}
	}
	this.moveUp(m.nextel!=-1?m.nextel:m.nexttop,num,y)
}
/********************************************************************************
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++
}

/********************************************************************************
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
}

Pff, became a big load hey ?
Hope you are willing to have a look at it, I'm completely stuck and waiting for someone to help me out...
 
Do it something like it with a function, say loadit(), call after fully loaded (onload handler) or anytime by user's intervention.
[tt]
function loadit() {
if (document.all && document.getElementById) {
var oscript=document.createElement("script");
if (oscript) {
oscript.type="text/javascript";
oscript.src=="../menu/mymenu.js";
}
document.getElementsByTagName("head")[0].appendChild (oscript);
oscript=null;
}
}
[/tt]
 
Hi tsuji,
Appreciate very much, but I have no clue what or where to put your code..
Sorry for being that newbie...
Can you point out how to use your code ?
Thanks a lot !!
 
Such as this.
[tt] <body onload="loadit()">[/tt]
 
pookie,

You don't say whether the second script works by itself. Can you confirm this? If it doesn't work by itself, then the problem lies within the script, rather than in the interaction between the scripts.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi Dan,
Yes, in fact, I got working on several other pages without problems. Just when this slidemenu comes in, the rightclick menu isn't there...(no errormessage either)
 
Oke, this the actual page where we're talking about, so where the slidemenu is working but the rightclick menu is not.
(By the way.. thank you very very much for your time !!!)
Code:
<?php
include("../../../Loginsys/include/session.php");
/* User is logged in */
if($session->logged_in){
	include("../../../header.php");
?>
<html>
<head>
<title>Actionshooting Nederland Competitiestanden</title>
<meta name="Author" content="Hans Vellekoop (web@actionshooting.nl)">
<style type="text/css">
div.clSlideMenu{ /* All slideMenu2 DIV elements */
	position:absolute;
	font-family:verdana,arial,helvetica;
	font-size:10px;
	overflow:hidden;
	width:150;
	height:22;
}
a.clA0{ /* All top level links */
	color:white;
	font-size:12px;
	text-decoration:none;
	font-weight:bold;
}
a.clA1{ /* All sub level links */
	color:black;
	font-size:11px;
	font-weight:bold;
	text-decoration:none;
}


/* NEEDED STYLES */
div.slideMenuBG{position:absolute; left:0; top:0; z-index:1}
div.slideMenuText{position:absolute; left:2; top:2; z-index:200;}
/* NEEDED ----- This class should be named like this:
	#NAME_OF_YOUR_MENUcont
*/
#slideMenucont{position:absolute;	height:600; width:200; visibility:hidden;}
body {
	background-image:  url(../../../images/bg_grad_frame_r.jpg);
}
.style1 {
	color: #FFFFFF;
	font-weight: bold;
	font-size: 18pt;
}
</style>


<script language="JavaScript" src="../../Klassmenu/slidemenu.js" type="text/javascript">
/**********************************************************************************
SlideMenu 2.0
*   Copyright (C) 2002 Thomas Brattli
*   This script was released at DHTMLCentral.com
*   Visit for more great scripts!
*   This may be used and changed freely as long as this msg is intact!
*   We will also appreciate any links you could give us.
*
*   Made by Thomas Brattli
*
*Script date: 08/05/2002 (keep this date to check versions)
*********************************************************************************/
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body marginleft="0" marginheight="0">
<span class="style1">2005
</span>
<script>
/*********************************
The actual script file is inside the
slidemenu.js file - remember to link 
that to your HTML file.
**********************************/

//Creating the menu object -- You can call it whatever you want - just remember to
//have the same name as the argument.
slideMenu = new createSlideMenu("slideMenu")

//Variables to set:
slideMenu.menuy=40 //The top placement of the menu.
slideMenu.menux=0 //The left placement of the menu
slideMenu.useImages = 1 //Are you using images or not?
slideMenu.pxspeed=20 //The pixel speed of the animation
slideMenu.timspeed=25 //The timer speed of the animation
slideMenu.inset = 10 //How much the selected items should pop to the left
slideMenu.arrow = 0 //Set this to className that has font-family:webdings
										//if you want to use the arrow feature. Note:
										//This ONLY works on DOM capable browsers, and with
										//useImages set to 0 - It's basically just a test I did.
										//I hope to improve it later on.

//Needed dummy classes - leave in the stylesheet!
slideMenu.bgClass =	"slideMenuBG"
slideMenu.txtClass = "slideMenuText"

/*******************************************************************************
Level properties - ALL properties have to be specified in level 0
This works the same way as the CM4 script (if you have used it)

The level[0] values will be the default value. Any value not specified
in higher levels will be inherited from level[0]. If anything
is spesified in level[1], but not in level[2], level[2] (sub2 menus)
will get the property value from level[1] and so on.

The availble values to control the menu by level are:

left           - The left placement of all items in the current level ( px value )
width          - The width of all items in the current level  ( px value )
height         - The height of all items in the current level  ( px value )
between        - The number of pixels between each item in  the current level ( px value)
className      - A name of a class specified in the stylesheet to control the
	               look of all items in this level. 
	               NOTE: The class MUST be in a stylesheet, and it most have position:absolute.
classNameA     - A name of a class specified in the stylesheet that will control the 
 								 Look of the TEXT for all items in this level. (you can also specify 
								 a hover class for this className to get a mouseover effect on the 
								 text.
regImage 			 - If you choose to use image feature of the script you have to
                 spesify the default image here.
roundImg       - This is the image that will used when a item is selected.
roundImg2      - This is the image used for sub-levels on the last item in a list.
								 (that's how the last items in this example are rounded on the sub-levels)
subImg         - The image used when the item has sub-items. Only in use for sub-levels
subRound       - Same as roundImg2 - only for items that have sub-items.

To understand the image setup see the images supplied with this script.
NOTE: Always specify the full (relative) path to the images!

The slideMenu_makeLevel function provides a shortcut to making levels.
If you are more comfortable with setting the properties by name you can
also set them like this:

slideMenu.level[0] = new Array()
slideMenu.level[0].left = 0
slideMenu.level[0].width = 138
..... and so on.

NOTE: In level 0 below I have included the names of the variables just for
readability - feel free to remove left = , width = , height = et cetera...
********************************************************************************/
slideMenu.level[0] = new slideMenu_makeLevel(
	left = 0,
	width = 138,
	height = 21,
	between = 5,
	className = "clSlideMenu",
	classNameA = "clA0",
	regImage = "level0_regular.gif",
	roundImg = "level0_round.gif",
	roundImg2 = "",
	subImg = "",
	subRound= "")
	
slideMenu.level[1] = new slideMenu_makeLevel(10,127,20,2,"clSlideMenu","clA1","level1_regular.gif","level1_round2.gif","level1_round.gif","level1_sub.gif", "level1_sub_round.gif")
slideMenu.level[2] = new slideMenu_makeLevel(21,118,18,2,"clSlideMenu","clA2","level2_regular.gif","level2_round2.gif","level2_round.gif", "level2_sub.gif", "level2_sub_round.gif")
slideMenu.level[3] = new slideMenu_makeLevel(33,108,20,2,"clSlideMenu","clA3","level3_regular.gif","level3_round2.gif","level3_round.gif","level3_sub.gif","level3_sub_round.gif")
slideMenu.level[4] = new slideMenu_makeLevel(40,107,19,2,"clSlideMenu","clA4","level4_regular.gif", "level4_round2.gif","level4_round.gif","level4_sub.gif", "level4_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)
}

/**********************************************************************
Making the menus is the same as in SlideMenu 1 only that now
you can make as many levels as you want.

NOTE: If you are converting from SlideMenu1 remember to add: theNameOfYourMenu.
in front of all menu creation calls.

The arguments to the makeMenu function are:

TYPE - top for top item, sub for sub item, sub2 for sub2 item, sub3 
       for sub3 item and so on (I've done it like that to keep it the same way as version 1)

TEXT - The link text for the item

TARGET - The target frame to open the links in. You do not have to spesify this if you
are not in a frame enviroment. (see below for more info)
------------------------------------------------------------
NOTE: I get mail about this all the time so I will try and explain more:
If you where to make a regular link that would open a link in another
frame you would probably do like this:
<a href="mylink.html" target="myOtherFrameName">Link</a>

To do the same for a slideMenu link you do like this:

slideMenu.makeMenu('top','My link','mylink.html','myOtherFrameName')
------------------------------------------------------------

mySlideMenu.makeMenu('TYPE','TEXT','LINK','TARGET')
************************************************************************/


//Menu 1 -----------------------
slideMenu.makeMenu('top','OKP')
    slideMenu.makeMenu('sub','Level A','../Klassement.php?level=A&klasseid=1','mainFrame')
	slideMenu.makeMenu('sub','Level B','../Klassement.php?level=B&klasseid=1','mainFrame')
	slideMenu.makeMenu('sub','Level C','../Klassement.php?level=C&klasseid=1','mainFrame')
//	slideMenu.makeMenu('sub','Level A','../OKP/KlassementOKP.php?level=A','mainFrame')

slideMenu.makeMenu('top','SKP')
	slideMenu.makeMenu('sub','Level A','../Klassement.php?level=A&klasseid=2','mainFrame')
	slideMenu.makeMenu('sub','Level B','../Klassement.php?level=B&klasseid=2','mainFrame')
	slideMenu.makeMenu('sub','Level C','../Klassement.php?level=C&klasseid=2','mainFrame')
slideMenu.makeMenu('top','OKR')
	slideMenu.makeMenu('sub','Level A','../Klassement.php?level=A&klasseid=3','mainFrame')
	slideMenu.makeMenu('sub','Level B','../Klassement.php?level=B&klasseid=3','mainFrame')
//	  slideMenu.makeMenu('sub','Categories')
//	  slideMenu.makeMenu('sub2','Menu scripts')
//	  slideMenu.makeMenu('sub2','Text scripts')
//	  	slideMenu.makeMenu('sub3','Menu scripts')
//	  	slideMenu.makeMenu('sub3','Text scripts')
//			slideMenu.makeMenu('sub3','Animation scripts')
//	  	slideMenu.makeMenu('sub3','Other scripts')   
slideMenu.makeMenu('top','SKR')
	slideMenu.makeMenu('sub','Level A','../Klassement.php?level=A&klasseid=4','mainFrame')
	slideMenu.makeMenu('sub','Level B','../Klassement.php?level=B&klasseid=4','mainFrame')
slideMenu.makeMenu('top','Wie in welk Level?')
slideMenu.makeMenu('sub','OKP')
	slideMenu.makeMenu('sub2','Level A','../level_05.php?level=A&klasseid=1','mainFrame')
	slideMenu.makeMenu('sub2','Level B','../level_05.php?level=B&klasseid=1','mainFrame')
	slideMenu.makeMenu('sub2','Level C','../level_05.php?level=C&klasseid=1','mainFrame')
		slideMenu.makeMenu('sub','SKP')
	slideMenu.makeMenu('sub2','Level A','../level_05.php?level=A&klasseid=2','mainFrame')
	slideMenu.makeMenu('sub2','Level B','../level_05.php?level=B&klasseid=2','mainFrame')
	slideMenu.makeMenu('sub2','Level C','../level_05.php?level=C&klasseid=2','mainFrame')
		slideMenu.makeMenu('sub','OKR')
	slideMenu.makeMenu('sub2','Level A','../level_05.php?level=A&klasseid=3','mainFrame')
	slideMenu.makeMenu('sub2','Level B','../level_05.php?level=B&klasseid=3','mainFrame')
		slideMenu.makeMenu('sub','SKR')
	slideMenu.makeMenu('sub2','Level A','../level_05.php?level=A&klasseid=4','mainFrame')
	slideMenu.makeMenu('sub2','Level B','../level_05.php?level=B&klasseid=4','mainFrame')
slideMenu.makeMenu('top','Hoeveel geschoten?','../count.php','mainFrame')

//Initiating the menu !! 
slideMenu.init()		

</script>
<body onload="loadit()">


</body>
<?
}
/* User is not logged in */
else{
?>
<body>
Je bent niet ingelogd, dus geen toegang tot deze pagina.
</body>

<?
}
?>
</html>
 
So what is wrong with you trying my advice? Have you tried at all or just some distraction?
 
Nothing is wrong with me.. (I think).
I tried to place your code here and there, but like I said, I have no clue where to put this. Things I did try did not work, but that's probably because I didn't put it on the right spot..
I'm not familiair with calling functions or js script at all.
So if you want me to try your code (I certainly do !) please show me in which file where to put it..
Thanks !

 
I think I answered that, did I not? Put the loadit() in your script section in the head. Add the onload="loadit()" in the body tag. That is for replacing and eliminating the attempt of document.write thing in your first post.
 
Oke, what I did:
On the page (compmenu posted above) I added
Code:
<script language="JavaScript" type="text/JavaScript">
<!--
function loadit() {
    if (document.all && document.getElementById) {
        var oscript=document.createElement("script");
        if (oscript) {
            oscript.type="text/javascript";
            oscript.src=="../../menu/mymenu.js";
        }
        document.getElementsByTagName("head")[0].appendChild (oscript);
        oscript=null;
    }
}
//-->
</script>

In the BODY tags of same page:
<body onload="loadit()">
Is this correct way and place ?
Is not working...
 
Basically that. But you said it does not work. However, I'm not in a position to read all your stuff. It's a long script! You've to look into them. Length is not a problem. What is important is the idea.

Here is a demo of concept. You can try to debug your page after the essential presented in the demo.

[1] The main page.
[tt]
<html>
<head>
<script language="javascript" src="a.js"></script>
<script language="javascript">
function loadit() {
if (document.all && document.getElementById) { //ie indicator---coarse grain
var oscript=document.createElement("script");
if (oscript) {
oscript.type="text/javascript";
oscript.src="b.js";
}
document.getElementsByTagName("head")[0].appendChild (oscript);
oscript=null;
}
}
</script>
</head>
<body>
<button onclick="loadit()">load external js if browser is ie</button><br />
<button onclick="a()">call function a() statically loaded</button><br />
<button onclick="b()">call function b() dynamically loaded</button><br />
</body>
</html>
[/tt]
[2] External script a.js at default vitual folder.
[tt]
function a() {
alert("function a() in a.js");
}
[/tt]
[3] External script b.js at default vitual folder.
[tt]
function b() {
alert("function b() in b.js");
}
[/tt]
This version use user's intervention so you have the leisure of plentiful time to see the effect. After "dynamically" loaded b.js, the function b() can be got called in ie, but not in moz, as designed.

 
Oke tsuji,
Great ! I'll get on with this tonight.
I post result back here tonight or tomorrow.

Thanks again for your effort !!
 
Working !!
Thanks a million again tsuji and Dan !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top