Jump to content

Dom Help


Matteo

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?

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...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...