Hi David,
krogstrup wrote:...Thanks for your answer - it works great
You're welcome.
krogstrup wrote:Do you understand my problem and do you have some idea on how to solve this.....?
Yes and Yes.
krogstrup wrote:...Then in the end of menu_data.js I use the function "spos" to move the menu to the correct left position. This works fine, but the menu first appears at position 0 for 1-2 secunds and is then moved to the correct position when the browser reaches my line with the "spos" function. Some of my customers has complained about this.
Some quick solutions might be:
(1) In your Main Menu, set the
left property to some large negative value (e.g.,
left = -1000;). The Main Menu will still make its first appearance in its pre-assigned location when the page loads,
but that location will be outside of the viewable area of the browser window. So, the user won't see the menu until your function moves it to its desired location. From the user's point of view, the menu makes its first appearance where it's supposed to be (and what they don't see, they don't know!) This above solution is probably the easiest if you want to stick with your functions, because it would require only one small change.
(2) You could also try setting
alwaysvisible = 0; in your Main Menu. Then you won't need to call mm_hideMenu() at the top of setLeftPosOfMainMenu(), because the menu will already be hidden. Then, when you call mm_showMenu() at the bottom of setLeftPosOfMainMenu(), pass a 1 as a second parameter, like so:
That will simultaneously (a) show the Main Menu and (b) set alwaysvisible = 1 in the Main Menu, so that once you show it, it remains on screen.
krogstrup wrote:So want I want to be able to do is this: I would like to use my "findLeftPos" script directly when specifying the left pos of the menu. Something like this:
Code: Select all
function getLeftPosOfMainMenu() {
var ie4_check = (document.all && !document.getElementById) ? true : false;
var ie5_check = (document.all && document.getElementById) ? true : false;
if (ie4_check || ie5_check) {
width = document.body.clientWidth;
}
else {
width = window.innerWidth;
}
intLeftPos = width/2-380
intLeftPos = intLeftPos + <%=intMainMenuLeftPos%>
return intLeftPos;
}
with(milonic=new menuname("Main Menu")){
style=mainStyle;
top=20;
left=getLeftPosOfMainMenu();
alwaysvisible=1;
orientation="horizontal";
aI("text=;url=;showmenu=menu");
}
But the code above does not work though I know for a fact that my function returns an integer for the left pos. Is it imposible to call a function when specifying the parameters for the menus ?
Yes, it is possible to use the return values of functions to set menu parameters. I've done the same sort of thing myself. I tried a test with your getLeftPosOfMainMenu() function (minus the asp code) and it worked fine. You say the code didn't work... how did it fail exactly? Was there an error message?
As a final comment, I have to mention that I think you might be making this too difficult. The menu system has positioning functions built in to do what it seems to me that you you're trying to do. For a site where the content is centered, you could position your menu using a left offset from center, using the
left and
screenposition menu properties. For example, to offset a menu 380 pixels from center, you would do like so:
Code: Select all
with(milonic=new menuname("Main Menu")){
style=mainStyle;
top=139;
screenposition="center";
left="offset=-380";
alwaysvisible=1;
orientation="horizontal";
aI(...
}
You can read more about this approach in
this sample. When you use screenposition, the menu also autmatically handles the onload and onresize positioning, so this may simplify the process for you.
Hope that helps,
Kevin