Jump to content

Dom Help


Matteo
 Share

Recommended Posts

I am trying to set a variable to the value of the object withvar elemContainer = document.getElementById('container');where 'container' is the id tag of the HTML div element. I want to the assign CSS positioning statements for style.top, style.bottom, style.left, and style.right for the div element 'container' using javascript. I want to dynamically resize the element when the browser is resized using Javascript, using the positioning statements listed. (NOTE: CSS percentages won't work for this project; I need to use absolute values based on browser size.)I have come up with the following:elemContainer.style.top() = contTop;where 'contTop' is a variable set to the screenWidth or Height, offset by the required size of the <div>, etc. for each of the positioning statements, but it doesn't populate (or propogate) the variables properly. I try to debug with Firebug and check the variable contents, but keep coming up with "null" values.Am I even on the right track?

Edited by Matteo
Link to comment
Share on other sites

I am trying to set a variable to the value of the object withvar elemContainer = document.getElementById('container');where 'container' is the id tag of the HTML div element. I want to the assign CSS positioning statements for style.top, style.bottom, style.left, and style.right for the div element 'container' using javascript. I want to dynamically resize the element when the browser is resized using Javascript, using the positioning statements listed. (NOTE: CSS percentages won't work for this project; I need to use absolute values based on browser size.)I have come up with the following:var contTop = elemContainer.style.top();etc. for each of the positioning statements, but it doesn't populate (or propogate) the variables properly. I try to debug with Firebug and check the variable contents, but keep coming up with "null" values.Am I even on the right track?
try:

var top ="100px", left="50px"; // etc...var elemContainer = document.getElementById('container')elemContainer.style.top = topelemContainer.style.left = left

etc...

Edited by Troy III
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...