Click to See Complete Forum and Search --> : copying DOM nodes


scarleton
March 11th, 2003, 09:51 PM
I am working on a new personal web site. You can view what I have so far by clicking here (http://www.miltonstreet.com/scarleton/). Everything works great except I would like the homepage to be centered on the page.

With the current homepage, I am using multiple divs with absolute positioning. All the definition div’s are positioned in the same place. On the onMouseOver and onMouseOut each div is being set to visible and hidden, respectably.

Because of the delicate positioning of all the divs, I figured the easies way to get the page to center is to convert the div’s into a table. Thanks to Dreamweaver, I have converted the page to tables, which can be seen here (http://www.miltonstreet.com/scarleton/test-table.html[/url).

Again I have placed hidden div’s with the definitions at the top of the page. The only thing I can figure is to look at the div as a DOM node and copy the whole contents into the div in the table. The only question is now. On the same note, is there a way to center all the absolute positioned div’s of the current homepage?

Sam
http://www.miltonstreet.com/images/nb-thumbnail.jpg (http://www.miltonstreet.com/~carleton/cars/tdi-newbeetle.html)

nategrover
March 12th, 2003, 04:19 PM
the style.visiblity of a DOM node will still allow it to be rendered, in other words, to take up space on the page.

The style.display property will actually stop it from being rendered at all. the "block" value displays, the "none" value hides it. This allows you to totally ignore positioning and just stack a bunch of elements one after another and turn them all to style.display = "none".

ie.

<DIV ID= DIV_1 STYLE="display:none"> test</DIV>
<DIV ID= DIV_2 STYLE="display:none"> test</DIV>

if you turn the display to "block" for only one of them at a time, they will both get swapped and shown in the same position on the page.

Then you just take all your divs and put them in the middle of a centered div or span or table or whatever you like.

Hope this helps.