Forum Moderators: open

Message Too Old, No Replies

Hide/Reveal a chunk of content

*sigh* my IE hide code don't work in Moz

         

Straynjer

3:11 am on Jul 22, 2004 (gmt 0)

10+ Year Member



I have some simple code to allow a user to reveal and hide chunks of content in a page. But clicking the show content button in Firefox Moz does nothing. What techniques are favoured here for this sort of interactivety?


<td> <a name="davidgover"></a>
<h3><br>
<img src="images/people/David-Gover_tn.jpg" width="56" height="56" align="left">Production Manager<br>
David Gover</h3>
<a href="#davidgover" onClick="document.all.davidgoverdetail.className='show'" onFocus="blur"><img src="images/lozenge-display.gif" name="displaybut12" border="0" id="displaybut12"></a>
<DIV class=hidden id=davidgoverdetail><A>
<p>David Gover <font size="-2">BE (forestry, hons.)</font></p>
<p>blah blah blah</p>
</a>
<div align="right"><a href="#andrewsparrow" onClick="document.all.davidgoverdetail.className='hidden'" onFocus="blur"><img src="images/lozenge-hide.gif" name="hidePerson12" border="0" id="hidePerson12"></a> </div>
</div>
</td>

Now that I look back on this I am wondering about the argumentless <a> tag around the hidden content. I created this a few months ago, and I think the <a> tag was just a kludge to make it work. I was only testing in MSIE back in those days of browser innocence.

klogger

3:23 am on Jul 22, 2004 (gmt 0)

10+ Year Member



document.all will only work in IE, using:

onClick='document.getElementById("davidgoverdetail").style.display="block"'

should work or:

onClick='document.getElementById("davidgoverdetail").className="show"'

but I don't use the .classname bit myself so the second version it is only a guess.

Straynjer

4:37 am on Jul 22, 2004 (gmt 0)

10+ Year Member



Hm, thanks for that - tried both versions, but neither work (in either IE or Moz).

klogger

6:56 pm on Jul 22, 2004 (gmt 0)

10+ Year Member



Little difficult to say without seeing the CSS definitions you are using and the rest of the page markup but this is a very basic example of showing and hiding things:

<html>
<head>
<style type="text/css">

#idHidden{
display:none;
width:200px;
background:#abcdef;
}

</style>
</head>

<body>

<a href="#" onclick="document.getElementById('idHidden').style.display='block'">Show div</a><br/>
<a href="#" onclick="document.getElementById('idHidden').style.display='none'">Hide div</a><br/>

<div id=idHidden>
Test
</div>

</body>
</html>