Back To Start Of Archive
Taken From The Forum: Archived Topics for the old Version 3.0 JavaScript Menu
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:31
Changing menu position after page have loaded?
Poster: toen_work
Dated: Thursday May 15 2003 - 10:43:41 BST
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
Poster: kevin3442
Dated: Thursday May 15 2003 - 15:59:59 BST
Hi Tommy,
You could use the following function so reset the menu's position
Code:
function mm_setPosition(top, left)
{
spos(gmobj("menu" + getMenuByName(menuName)),top,left,null,null);
}
{
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:
function mm_showMenu(menuName)
{
var menuNum = getMenuByName(menuName);
var menuArr = eval("menu" + menuNum);
menuArr[7] = 1;
SDiv("menu" + menuNum, 1);
}
{
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