View Full Version : Java Menu help...
linksanime2003
11-03-2003, 04:19 PM
I don't know anything about JavaScript, but I need to know this.
I have a menu script, but it draws the menu according to pixels. So, if I set the menu to start at 600x10, a user with a resolution lower than that can't use the menu correctly. (I used HTML to take off the scrollbar on the page, so no scrolling.)
Can I add like IF statements and stuff to make it look for screen resolution, then set the start pixels accordingly?
whirlybird540
11-05-2003, 02:25 PM
There is a better way then setting your menu at certain point in the screen. What I did for one of my project is lets say a link is what initilizes the drop down. I want the menu to appear right below the link. What you can do is find out the position of the link and display the menu a couple of pixels below it. To to this you need to do some looping to find out exactly where in the page the link is
. Where item is the link. offsetLeft is a property of all objects which tells its offset from the top of its container.
function getWindowOffsetLeft(item)
{
var offset = item.offsetLeft;
var parent = item.offsetParent;
while(parent.tagName!="BODY")
{
offset += parent.offsetLeft;
parent = parent.offsetParent;
}
return offset;
}
function getWindowOffsetTop(item)
{
var offset = item.offsetTop;
var parent = item.offsetParent;
while(parent.tagName!="BODY")
{
offset += parent.offsetTop;
parent = parent.offsetParent;
}
return offset;
}
After you get the offsets, just set your menu.style.left and top equal to the offsets that are returned. Plus a couple more pixels to make it just below it or to the right of it.
linksanime2003
11-05-2003, 03:42 PM
Thanks whirlybird540! I've already been given a couple solutions to my problem through other threads, but I am going to try every one to see what works best.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.