Changing menu position after page have loaded?

Please note that official support for this menu version has now ceased. There are still plenty of users, though, and the forum is still running. Some of our long-time users may be able to help you out.
Post Reply
toen_work
Beginner
Beginner
Posts: 7
Joined: Thu May 15, 2003 10:36 am

Changing menu position after page have loaded?

Post by toen_work »

Hi all,

I need a fix for a Netscape 6 problem. I have the content of my site centered using a table. I align my top menu by calculating the left position using window.innerWidth and the width of the table. However, the menu scripts (and therefore also the calculations) have to be placed at the beginning of the page (right after the body tag), due to performance problems in Netscape 4 and when using Flash. The problem that arises is that Netscape 6 returns the width of the window without the vertical scrollbar, but when the content is loaded, the scrollbar suddenly appears and messes up the menu position. I've tried to find a work-around, but nothing seems to do it.

So, is there a way to change the position of a menu after it's created? The positions of the submenus would obviously have to be changed as well.

Thanks in advance!

/Tommy
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi Tommy,

You could use the following function so reset the menu's position

Code: Select all

function mm_setPosition(top, left)
{
  spos(gmobj("menu" + getMenuByName(menuName)),top,left,null,null);
}
Note, however, that if you move the menu while it is visible to the user, it may appear to "jump" - it would be more obvious on slower connections. To avoid that you could set the initial Top and/or Left coordinates in the menu array so that the menu is off of the screen at first (use negative values), for all browsers, then use the above function to move the menu into view - again for all browsers. Apply the necessary adjustment to the top and left parameters for NS6 prior to the function call.

If positioning the menu off of the visible page doesn't appeal to you, another approach would be to set the menu's Always Visible property (8th element in the array) to 0 so that it isn't visible at first. When the page loads, adjust the position as necessary using the above function, then "turn the menu on" with this function:

Code: Select all

function mm_showMenu(menuName)
{
  var menuNum = getMenuByName(menuName);
  var menuArr = eval("menu" + menuNum);
  menuArr[7] = 1;
  SDiv("menu" + menuNum, 1);
}
The above function displays the menus and turns Always Visible on, so that the menu will remain on screen once you display it. In these function calls, the menuName is the name of your menu as defined in the first element of the menu array. You would, of course, wrap these functions in one of your own making, where you detect what browser is used and calculate the necessary adjustment for NS6... you'd call that function from the body's onload event.

Hope that helps,

Kevin
Last edited by kevin3442 on Thu May 15, 2003 4:40 pm, edited 1 time in total.
toen_work
Beginner
Beginner
Posts: 7
Joined: Thu May 15, 2003 10:36 am

Post by toen_work »

Thanks Kevin. I'll try this out tomorrow, but it feels very promising! :D
toen_work
Beginner
Beginner
Posts: 7
Joined: Thu May 15, 2003 10:36 am

Post by toen_work »

Sorry for not getting back earlier, but your suggestion worked a treat, Kevin! Thanks for saving my sanity! :mrgreen:
Post Reply