Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-19-2003, 05:21 AM   PM User | #1
"Q"
New to the CF scene

 
Join Date: Feb 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
"Q" is an unknown quantity at this point
Using DOM to locate a menu on the screen. Code not working

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" is offline   Reply With Quote
Old 02-24-2003, 02:31 AM   PM User | #2
"Q"
New to the CF scene

 
Join Date: Feb 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
"Q" is an unknown quantity at this point
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,
"Q" is offline   Reply With Quote
Old 02-25-2003, 04:23 PM   PM User | #3
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
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
__________________
My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
“Minds are like parachutes. They don't work unless they are open”
“Maturity is simply knowing when to not be immature”
beetle is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:03 AM.


Advertisement
Log in to turn off these ads.