...

Using DOM to locate a menu on the screen. Code not working

"Q"
02-19-2003, 05:21 AM
I have spent over 2 hours trying many variables to get a simple picture to move to the correct x and y position on the screen. To view the code please go to www.lybroworld.com.

You will notice a red bar with links "menu 1" and "menu 2". When you click on them the desired affect is to have the pics line up under the correct heading but instead the top position is not working but the left is ok. What I don't under stand is that if you click on the other 2 random links the images line up.

This leads me to belive that I am not accessing the DOM correctly in the menu bar as it works on the other two links properly.

I am still a newbie with JavaScript so don't flame me for my lame code. I am trying to keep it simple until I quite making dumb mistakes so that I can debug it easier.

Thanks,

Matt

"Q"
02-24-2003, 02:31 AM
WOOOOHOOOO:) I figured it out.

I had this code

function setTop(anchor) { var dom = document.getElementById(anchor);

return dom.offsetHeight + dom.offsetTop + 5}

The problem was with how JavaScript convets the strings and how CSS used the output. I added "5px" and the problem was resolved.

I have to go back and do more reading on this to fully grasp it but that was the basic fix for this problem. The code on my example is not perfect yet there are still some bugs in it regarding the other links on the screen and element positioning but I can finally see the light

Later,

beetle
02-25-2003, 04:23 PM
That is accurate, any position you set should have the unit appended to it. Remember, style rules are strings, even if they look like numbers ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum