Help with this Javascript

  • Thread starter Thread starter Impreza04
  • 3 comments
  • 568 views
Messages
1,007
United Kingdom
Kent, UK
This problem has been existant for a while, this javascript forms a floating menu that follows the page fine, in IE and Opera, however in Firefox, it gets stuck..

Example: http://forums.shockv2.net

The javascript is
Code:
ie=document.all?1:0
n=document.layers?1:0
//Do you want it to move with the page if the user scroll the page?
var moveOnScroll=true
numberOfMenus=5//How many menus do you have
//Do you want to hide all the other submenus when you click a new?
var hideAll=true
function makeMenuBar(obj,nest,vis){
    nest=(!nest) ? '':'document.'+nest+'.'
    this.css=(n) ? eval(nest+'document.'+obj):eval(obj+'.style')
	this.hideIt=b_hideIt;	this.showIt=b_showIt					
	if(ie && vis) this.css.visibility='hidden'
	this.evnt=(n)? eval(nest+'document.'+obj):eval(obj);	
	this.go=0
	this.height=n?this.css.document.height:eval(obj+'.offsetHeight')
	this.top=b_gettop
    this.obj = obj + "Object"; 	eval(this.obj + "=this")	
}
//Get's the top position.
function b_gettop(){
	var gleft=(n) ? eval(this.css.top):eval(this.css.pixelTop);
	return gleft;
}
//The functions for showing and hiding
function b_showIt(){
	this.css.visibility="visible"
}
function b_hideIt(){
	this.css.visibility="hidden"
}
function checkScrolled(){
	if(!oMenu.go)oMenu.css.top=(!oMenu.state)?eval(scrolled):eval(scrolled)
	if(n) setTimeout('checkScrolled()',30)
}
function menuBarInit(){
	oSub=new Array()
	oTop=new Array()
	for(i=0;i<numberOfMenus;i++){
		oTop[i]=new makeMenuBar('divTop'+i,'divBg')
		oSub[i]=new makeMenuBar('divSub'+i,'divBg.document.divTop'+i,1)
		oSub[i].evnt.onmouseout=evOut;
	}
	//Moving menuBar
	oMenu=new makeMenuBar('divBg')
	scrolled=n?"window.pageYOffset":"document.body.scrollTop"
	oMenu.css.top=eval(scrolled)
	oMenu.css.visibility='visible'
	if(moveOnScroll) ie?window.onscroll=checkScrolled:checkScrolled();
}
function evOut(){
	if(ie)this.style.visibility='hidden'
	else if(n) this.visibility='hidden'
}
//Canceling event bubbling in ie
function ieShow(num){
	if(ie){
		oSub[num].showIt()
		window.event.cancelBubble=true
	}
}
function extract(num){
	if(hideAll){
		for(i=0;i<oSub.length;i++){
			if(num!=i) oSub[i].hideIt()
		}
	}
	oSub[num].showIt();
}
onload=menuBarInit;

If you can se/notice anything there that is causing this can you let me know.. It'd be great to get this fixed :)
 
This is about the only thing that I saw that might help. Hope that works for you.
 
Well, here is a solution to avoid editing the javascript. You could try and push the whole template (the top table) down a couple of lines so that there is more room for the javascript.

Open overall_header.tpl in /templates/SwiftBlue/overall_header.tpl

Then find the line -
Code:
<!-- Menu end -->
<script language="javascript1.2" type="text/javascript" src="templates/hidebbcode.js"></script>
<body bgcolor="{T_BODY_BGCOLOR}" text="{T_BODY_TEXT}" link="{T_BODY_LINK}" vlink="{T_BODY_VLINK}">

<a name="top"></a>
<!-- start : mod LoginBoxAtOverallHeader by maxJackal --> 
<!-- BEGIN switch_user_logged_out --> 
<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center"> 
<tr> 
<form method="post" action="{S_LOGIN_ACTION}">

Insert a few breaks above the table. I don't know exactly how many you would need, but you can play around with it.

Here is an example -
Code:
<!-- Menu end -->
<script language="javascript1.2" type="text/javascript" src="templates/hidebbcode.js"></script>
<body bgcolor="{T_BODY_BGCOLOR}" text="{T_BODY_TEXT}" link="{T_BODY_LINK}" vlink="{T_BODY_VLINK}">

<a name="top"></a>
<!-- start : mod LoginBoxAtOverallHeader by maxJackal --> 
<!-- BEGIN switch_user_logged_out --> 
<br /><br /><br /><br />
<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center"> 
<tr> 
<form method="post" action="{S_LOGIN_ACTION}">
 
Back