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("menu1", "down", 0, 100, 180, 50)
var myMenu2 = new TopicMenu("menu2", "down", 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 + "px" : myMenu.container.left = newLeft;
var newLeft = getWindowWidth() / 2 + myOffset2; myMenu.container.style ? myMenu2.container.style.left = newLeft + "px" : myMenu2.container.left = newLeft;
}
function getWindowWidth()
{
return window.innerWidth ? window.innerWidth : document.body.offsetWidth;
}
</SCRIPT>
Thanks
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("menu1", "down", 0, 100, 180, 50)
var myMenu2 = new TopicMenu("menu2", "down", 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 + "px" : myMenu.container.left = newLeft;
var newLeft = getWindowWidth() / 2 + myOffset2; myMenu.container.style ? myMenu2.container.style.left = newLeft + "px" : myMenu2.container.left = newLeft;
}
function getWindowWidth()
{
return window.innerWidth ? window.innerWidth : document.body.offsetWidth;
}
</SCRIPT>
Thanks