Display: None | Block;

javascript question

Page 1 of 1

2 Replies - 52648 Views - Last Post: 08 April 2003 - 12:26 AM

#1 supernova333  Icon User is offline

  • D.I.C Addict

Reputation: 4
  • View blog
  • Posts: 590
  • Joined: 12-March 02

Display: None | Block;

Posted 07 April 2003 - 09:39 PM

I usually stay away from dynamically hiding and showing layers because of older browser support, but for this project it doesn't matter. I just want this to work in IE 5+ and NN6+ so it seems like it should be easy.

I am trying to make a link or div that you can click and have another div appear under it. Ideally i want it to use the css display: inline and none attributes to have the div make room when it appears. I am actually using classes and things but here is a basic example of what works in IE:

<div id="news1" onclick="news2.style.display='inline';">Find out what we've been up to.</div>
<div id="news2" style="display: none;">Well, here is all the news about us...</div>


What do I need to make this effect work in Netscape/Mozilla?

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Display: None | Block;

#2 supernova333  Icon User is offline

  • D.I.C Addict

Reputation: 4
  • View blog
  • Posts: 590
  • Joined: 12-March 02

Re: Display: None | Block;

Posted 07 April 2003 - 09:57 PM

I've been searching all night for this and I find out about the getElementById() function a few minutes after I post:

function showLayer(layerName)
{
	if (document.getElementById) // Netscape 6 and IE 5+
	{
  var targetElement = document.getElementById(layerName);
  targetElement.style.display = 'block';
	}
}

function hideLayer(layerName)
{
	if (document.getElementById) 
	{
  var targetElement = document.getElementById(layerName);
  targetElement.style.display = 'none';
	}
}



Thanks anyway :)
Was This Post Helpful? 0
  • +
  • -

#3 codeman  Icon User is offline

  • w3c fanatic

Reputation: 3
  • View blog
  • Posts: 1,190
  • Joined: 13-August 01

Re: Display: None | Block;

Posted 08 April 2003 - 12:26 AM

Yes, it's quite useful. Find more cool stuff regarding the DOM at http://www.brainjar.com
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1