πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.javascript
2 messages
2 total messages Started by Veronique Quiby Tue, 09 Jan 2001 16:52
NN6,IE5: setting DIV attribute height when undefined ?
#54
Author: Veronique Quiby
Date: Tue, 09 Jan 2001 16:52
42 lines
2498 bytes
Hi,

I'm doing a project which should turn on Netscape 6 and Internet
Explorer 5.

My problem is:

I have different <div> elements and some of them should be hidden
onloading. For example:

<div id="1"> blablabla </div>
<div id="2" style="visibility:hidden"> blablabla </div>
<div id="3"> blablabla </div>
...

When my page is loaded, div id=2 is hidden. Therefore there is a hole
between div 1 and 3.
I would like to move up div id=3.
Thus I need height of div id=2 in order to assign height of div id=3 to
this value.

I don't want to calculate all the different heights (<div>).

I have tried among others this code (onloading and after loading with a
button):

var div = document.getElementsByTagName("div");
alert("Value of height for div[0]:  "+ div[0].getAttribute("height"));

There is no value on the alert window.

This let me suppose that the browser (IE and NN), after calculating the
best position for every element, don't assign the
value of attributes (that are not present in the html file). But I am
not sure.

Does somebody have an answer or alternative to my problem ?

Many thanks.

VΓ©ro
Re: NN6,IE5: setting DIV attribute height when undefined ?
#55
Author: Wolfgang Schwarz
Date: Tue, 09 Jan 2001 17:33
27 lines
2049 bytes
hi,

Veronique Quiby wrote:

> <div id="1"> blablabla </div>
> <div id="2" style="visibility:hidden"> blablabla </div>
> <div id="3"> blablabla </div>

> When my page is loaded, div id=2 is hidden. Therefore there is a hole
> between div 1 and 3.
> I would like to move up div id=3.

use "display:none" instead of "visibility:hidden".

> var div = document.getElementsByTagName("div");
> alert("Value of height for div[0]:  "+ div[0].getAttribute("height"));
> There is no value on the alert window.

sure. You haven't set an attribute "height" in the DIV tag, have you?
There are ways to get the computed size of elements, but I guess you
don't need them anymore... ;-)

wo.

BTW: Your choice of newsgroups was a bit strange. What about
comp.lang.javascript next time?
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads