views:

125

answers:

1

I'm trying to center a page on any resolution while still being able to use absolute positioning to move pictures. I figure that the best way would be to have a table positioned relatively in the beginning in the center of the page, then change it to absolute positioning in the onload of the page. I think the correct line is:

document.getElementById("Object").style.position = "absolute";

However, I put an alert box after it asking where the left side of the object is, I get undefined. But, if I directly assign it to a position (Object.style.left = 500) I will get that number. So I can assign it a value, meaning it is in absolute position, but I cannot pull a value out of that. Kind of confusing but hopefully it makes sense and someone knows what to do. Thanks.

A: 

use document.getElementById("elementName").offsetLeft to find the position of an object
relative to its parent-container's position [in your case, document.body]
You're accessing the CSS style object's left parameter, which is different.

ItzWarty
Thanks, I got the numbers I needed. It works.
Doug