Click to See Complete Forum and Search --> : Hiding Images


Hani79
03-19-2003, 03:23 PM
I've been looking around and have found no solutions for this thus far:

I have a webpage that has a small 93px image that I would like not to show up when the page is loaded. However, I have no control of that being a part of the body.

I have tried to use layers to cover the images, but it loads right before the layer does, and thus, you catch a glimpse of it.

Is there any possible way to add code into the <head> of the page that will either suppress the image or at least substitute it for another one if I supply the location of the substitute image?

I truly appreciate any help I can get with this one!

Jona
03-19-2003, 03:48 PM
Probably something like this:

<script>
document.images["imageName"].style.visibility="hidden"
</script>

If that doesn't work, try taking out the "style" part of it.

Hani79
03-19-2003, 03:57 PM
Thanks for your reply, Jona.

I gave that a whirl, and it doesn't seem to work. I tried removing .style as well, with no luck.

I attempted to put the entire directory location of the file as well (as opposed to my original trial of just the filename of the image) - but that made no difference.

Any other ideas? (Thanks again!)

Jona
03-19-2003, 04:07 PM
You mean you can't do: <img src="someimage.jpg" style="visibility:hidden"> ?

Oh well..... I don't know the CSS style for it.

Hani79
03-19-2003, 04:10 PM
Unfortunately, I can't do that since I have no abilities to edit the part of the page's code that contains the image code.

Jona
03-19-2003, 04:13 PM
If you hold on for a second, I'll go and see if I can find the code somewhere...

Hani79
03-19-2003, 04:14 PM
Well, I kinda got this to work:

<script language="javascript">
function onLoad()
{
document.images(0).style.visibility="hidden" }
</script>

<body onLoad="onLoad();">


However,
This still results in a quick glimpse of the image.

Is there a way to have the function load before the body tag?

Jona
03-19-2003, 04:19 PM
Yes there is. To do that, just don't use an onLoad() function at all. Just type in: document.images(0).style....etc. However, the only problem with that is you will get an error. Because it executes before the page (or the image) has loaded, it will say that the object does not exist.

Hani79
03-19-2003, 04:25 PM
Hmmmm....that didn't seem to give me an error or run the script. If you think of anything else that might work for it, I'd be indebted greatly!