JavaScript: Change to Absolute Positioning

Posted by Doug on Stack Overflow See other posts from Stack Overflow or by Doug
Published on 2010-04-15T04:57:19Z Indexed on 2010/04/15 5:03 UTC
Read the original article Hit count: 297

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.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about absolute-positioning