View Full Version : Set Visibility

02-01-2007, 09:21 PM
Hi, hope someone can help. I'm trying to change the visibility of text and an image on a gallery page. I have the following html code:

<img src="#" id="pic" style="visibility:hidden;" />
<p id="temptext" style="visibility:visible;">Please click a thumbnail....</p>
<div id="hide" style="visibility:hidden;">stuff to be hidden</div>

And have a function which displays the correct image and hides what needs to be hidden:

function showPic(i,x,y) {
document.getElementById('pic').style.visibility = "visible";
document.getElementById('temptext').style.visibility = "hidden";
document.getElementById('hide').style.visibility = "visible";

This works fine in FF but as per usual not in IE. I know the function is loading the image; its just not overwriting the visibility setting. I've tried adding the initial visibility style to the external style sheet instead of having it in the html code but it doesn't seem to make any difference. I've also tried setting the visibilities via an onload function, but that didn't work either! And i've tried using the display property instead of visibility.

Please help! Thanks for reading :)

02-01-2007, 10:34 PM
try in the html:
style="" (for the visible)
style="display:none" (for the invisible)

and in the java script:

function showPic(i,x,y) {
document.getElementById('pic').style.display = "";
document.getElementById('temptext').style.display = "none";
document.getElementById('hide').style.display = "";

02-02-2007, 12:20 AM
Thank you, but it didn't work. It seemed to stop the images being loaded completely....again, just in IE7; it still works ok in FF.

02-02-2007, 12:29 AM
IE7 problem maybe? hve you got the newest IE7 updates?

what you are trying has always worked in IE6 should work now to......

02-02-2007, 12:44 AM
Yep, i've recently upgraded to IE7 so it should be the most up to date version. I also have earlier versions of IE installed and it's not working on them either :confused:

neither firefox or opera have any problem with the code...ugh i hate IE!!

thanks for the suggestions so far (keep 'em coming! :p )