Page 1 of 1

Displaying hidden DIVs in netscape using javascript

Posted: Tue Aug 12, 2003 3:04 pm
by kendall
Hello,

i currently have the following script

Code: Select all

<!--
var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);
var ns7 = (document.all && document.getElementById);

function attach(id)
&#123;
var obj
if(ns4) obj=document.layers&#1111;id];
else if(ie4) obj = document.all&#1111;id];
else if(ie5 || ie6) obj = document.getElementById(id);
return obj
&#125;

function toggleVisibility(id)
&#123;
temp_obj = attach(id);
if(ns4)
if (temp_obj.display=="none") temp_obj.display="";
else temp_obj.display="none";
else if (temp_obj.style.display == "none")
temp_obj.style.display = "";
else temp_obj.style.display = "none";
&#125;
this allows me to show/ hide the div tags on a onClick()

my problem is the handling of this script with netscape...i get it to work with IE all versions but not netscape not even v7

does anyone have the formula for netscape?

Kendall

Posted: Tue Aug 12, 2003 3:36 pm
by Seth_[php.pl]
I'm not sure if it help you but there is an Alladyn project written by Polish :] team. It is:
Alladyn is DHTML library that unifique DOM of browsers, and holds powerfull animator to make pages really dynamic
You can download it from alladyn.art.pl (there is an english version of site). Recently i couldn't get into site but maybe it's temporary.

Here you have a list of DHTML libraries that can help you too: http://www.timmorgan.info/dhtml/libraries/

Posted: Sat Aug 16, 2003 2:22 pm
by Skyzyx
According to your code, you haven't written anything for Netscape. Here's some modified code that should work.

ns4 = Netscape 4.x. Supports document.layers()

ie4 = Internet Explorer 4.0x. Supports document.all()

dom = Any browser that supports document.getElementById(). Includes IE5+/Windows, IE5/Mac, Opera 7, and Gecko (including Netscape 6+, Mozilla, Firebird, Camino, Galeon, K-Meleon, AOL for Mac OS X, CompuServe 7, etc.).

Code: Select all

<script language="javascript" type="text/javascript">
<!--
var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var dom = (document.getElementById);

function attach(id)
&#123;
	var obj;

	if (ns4) obj=document.layers&#1111;id];
	else if (ie4) obj=document.all&#1111;id];
	else if (dom) obj=document.getElementById(id);

	return obj;
&#125;

function toggleVisibility(id)
&#123;
	temp_obj = attach(id);

	if (temp_obj.style.display == "none") temp_obj.style.display = "";
	else temp_obj.style.display = "none";
&#125;
//-->
</script>