Displaying hidden DIVs in netscape using javascript

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Displaying hidden DIVs in netscape using javascript

Post 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
User avatar
Seth_[php.pl]
Forum Commoner
Posts: 30
Joined: Sun Aug 10, 2003 5:25 am
Location: Warsaw / Poland

Post 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/
Skyzyx
Forum Commoner
Posts: 42
Joined: Fri Feb 14, 2003 1:53 am
Location: San Jose, CA

Post 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>
Post Reply