PDA

View Full Version : netscape support for div tags?


kamarthi7
04-30-2003, 10:28 AM
Is it possible to display and hide the div elements on click in netscape.

for example

<html>
<head>
<script language="javascript">
function toggle(id)
{
if(document.getElementById(id).style.display=="none")
document.getElementById(id).style.display="block";
else
document.getElementById(id).style.display="none";
}
</script>
</head>
<body>
<a href="javascript:void(null);" onclick="toggle('toggleMe');">click here</a>
<div ID="toggleMe" style="display:none">some text here</div>
<br><a href="javascript:void(null);">nothing</a>
</body>
</html>

this code perfectly works in IE. but is posible to do it in netscape 4.x. if yes how please.

thank you....

ANIL

Roy Sinclair
04-30-2003, 04:35 PM
It is possible in Netscape 4 but only if the <div> is declared with a style of "position: absolute" or "position: relative". Don't expect the page to rearrange because Netscape 4 doesn't do dynamic and Netscape 4 also doesn't support getElementById (it predates that standard) so you'll have to look for your divs within the proprietary "layers" collection. Also be aware that each of those "layers" is it's own complete window (much like an IFRAME) so no content within them will be found in the local window (this means you can't put form elements into a layer and expect the form elements in that layer to be part of a form that's declared outside the layer.

NS 4 is obsolete, if you don't have to support it then don't try. If you do have to support it, you're better off finding a way to degrade gracefully rather than try to match any fancy dhtml effects (simple effects like rollovers aren't too hard though).