Click to See Complete Forum and Search --> : Show/Hide in Netscape 4


JSchwarz
07-24-2003, 12:24 PM
Can you show and hide elements in Netscape 4? Netscape doesn't recognize absolute positioning; is there another way to show and hide elements in v4.7?

Thanks,
Jeff

gil davis
07-24-2003, 01:25 PM
Originally posted by JSchwarz
Can you show and hide elements in Netscape 4?Yes.
Netscape doesn't recognize absolute positioning;Yes it does. You must not have done it correctly.
is there another way to show and hide elements in v4.7?You have not shown the way you are trying yet. How could we tell you another way?

<div id="d1" style="position:absolute; visibility: visible; top: 200px; left:200 px; border: 1pt solid black">this is an absolute positioned DIV</div>
<a href="#" onclick="document.layers['d1'].visibility = (document.layers['d1'].visibility == 'show') ? 'hide' : 'show';return false">click here to show/hide the DIV</a>

JSchwarz
07-24-2003, 01:37 PM
This works, but unfortunately it screws up everthing that comes after it on the form. See this (http://forums.webdeveloper.com/showthread.php?s=&threadid=13033).

Is there any way to work around this; or a way to show and hide without absolute positioning?

Thanks,
Jeff

gil davis
07-24-2003, 09:26 PM
How about this, then?
<a href="#" onclick="document.layers['d1'].visibility = (document.layers['d1'].visibility == 'show') ? 'hide' : 'show';return false">click here to show/hide the SPAN</a>
<br><br><br>
<span id="d1" style="position: relative; visibility: visible; border: 1pt solid black">this is a relative positioned SPAN</span>
The "problem" is that NS 4 treats an absolute object as *never* existing in the flow of the document, whereas IE will only treat the absolute object out of the flow if you give it top and left attributes.

You can fool it by placing an absolute object inside a relative object, but the relative object must somehow be sized to accomodate the absolute object. It won't take up any space in the document without some help. But that's really what an absolute object *should* do, and IE really doesn't follow that at all.

If you have to stand on your head too much to make it cross-browser just for an error message, why not throw the whole span idea out the window and use an image swap? That would be less coding, and they don't need to be complex images.