/    Sign up×
Community /Pin to ProfileBookmark

Problem with Drop Down Menu

I have a javascript drop down menu throughout my site, i have a problem with the positioning in different resolution.

<script>

function expand(s, m)
{
var browser = window.navigator.appName;
var dif = 0;
if (browser != “Microsoft Internet Explorer”) { dif = 12; }

var d = document.getElementById(m);
var td = document.getElementById(s);
var left = td.offsetLeft + 50;
var top = td.offsetTop + 108;
var width = td.offsetWidth – dif;

td.style.color = “#FFFFFF”;

d.style.top = top;
d.style.left = left;
d.style.width = width;
d.style.position = “absolute”;
d.style.visibility = “visible”;
d.style.display = “block”;
}

function collapse(s, m)
{
var d = document.getElementById(m);
var td = document.getElementById(s);

td.style.color = “black”;

d.style.position = “static”;
d.style.visibility = “hidden”;
d.style.display = “none”;
}

function collapseAll()
{
var menuDiv = document.getElementById(“menu”);
var divs = menuDiv.getElementsByTagName(“div”);
var div;

for (i = 0; i < divs.length; i++)
{
div = divs[i];
div.style.visibility = “hidden”;
div.style.display = “none”;
}
}
</script>

var left = td.offsetLeft + 50; this lines states were the drop down is positioned from the left hand side, i need this to be constant whatever resolution it is at?

Any Ideas?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceJun 02.2006 — The screen dimensions are as follows:

screen.width

screen.height

screen.availWidth

screen.availHeight

and in Mozilla (not IE6):

screen.availLeft

screen.availTop
Copy linkTweet thisAlerts:
@jk1984authorJun 05.2006 — Not sure exactly how that helps me could you clarify?
Copy linkTweet thisAlerts:
@phpnoviceJun 05.2006 — You said you had a problem with the positioning in different resolutions. So, I thought I'd post the properties where you can find out what is the current resolution and use that information in your calculations. No?
Copy linkTweet thisAlerts:
@jk1984authorJun 05.2006 — I am not to hot on javascript really but that makes sense, so i will have to try and find out exactly what i will have to do to make sure it positioned correctly!
×

Success!

Help @jk1984 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...