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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Small Javascript problem

Status
Not open for further replies.

BobTB

Technical User
Oct 28, 2002
37
AU
I am trying to implement this script for a menu but have a small problem.........I need to have more than one menu on the same page but I am not sure of the correct coding to do this.....I am part of the way there but can some one tell me how to code the following line for multiple menus.

The original line is.... myMenu.onactivate = repositionMenu


The full modified script , excluding the external menu script is shown below..

<SCRIPT language=javascript>

var myOffset = -50;
var myOffset2 = -20;

// the number you pass to initLeft doesn't matter since it will get
// changed onactivate
var myMenu = new TopicMenu(&quot;menu1&quot;, &quot;down&quot;, 0, 100, 180, 50)
var myMenu2 = new TopicMenu(&quot;menu2&quot;, &quot;down&quot;, 0, 150, 180, 50)
//********* The line below is the problem....how do I code this line to accept myMenu2 as well???

myMenu.onactivate = repositionMenu

//**********
function repositionMenu()
{
var newLeft = getWindowWidth() / 2 + myOffset;
myMenu.container.style ? myMenu.container.style.left = newLeft + &quot;px&quot; : myMenu.container.left = newLeft;
var newLeft = getWindowWidth() / 2 + myOffset2; myMenu.container.style ? myMenu2.container.style.left = newLeft + &quot;px&quot; : myMenu2.container.left = newLeft;
}

function getWindowWidth()
{
return window.innerWidth ? window.innerWidth : document.body.offsetWidth;
}

</SCRIPT>


Thanks
 
Could you post the entire code(including external .js files) or a place to get it? It is hard to fix if I can't try it. So, if you could just give me the link of where you got it, that would help...
 
Hi Adam

I fixed the problem...... something as simple as the line below........I must have lost a few brain cells somewhere, lol

myMenu.onactivate = repositionMenu; myMenu2.onactivate = repositionMenu;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top