|
-
Feb 25th, 2001, 07:41 AM
#1
How to hide an image using script?
-
Feb 25th, 2001, 03:56 PM
#2
Fanatic Member
You can wrap your image in a <DIV></DIV> and then set the <DIV>'s visibility property to hidden.
<script>
div1.visibility = 'hidden';
</script>
<div ID = "div1">
<img SRC = "/myimage.gif">
</div>
You can then display it again in script by setting the same property to 'visible'.
-
Feb 25th, 2001, 08:00 PM
#3
thanks very much...
i didn't know the property was .visibility
i kept trying div1.visible=false..
Thanks a lot!
-
Feb 25th, 2001, 11:43 PM
#4
but this isn't working either
-
Feb 26th, 2001, 11:59 AM
#5
Fanatic Member
Add this style in the document head:
<style>
#div1 {visibility:hidden;}
</style>
Give the <DIV> and ID of div1
<div ID = "div1"><img SRC = "/myImage.gif"></div>
That should do it.
In order to access a style in script it must be defined in the document. Sorry, my mistake. To access this attribute from script to hide or show it you could then use this syntax:
div1.style.visibility = 'visible';
div1.style.visibility = 'hidden';
-
Feb 26th, 2001, 07:09 PM
#6
oh yes i figured it out later.. thanks anyway..
I used div1.style.display = "none" .. this won't work in Netscape
Will your code work in Netscape?
-
Feb 26th, 2001, 11:55 PM
#7
Fanatic Member
Netscape doesn't support the ".style" in code. There is a way to access it in Netscape but I'm not totally sure of the proper syntax and I don't have it installed to test it out, sorry.
-
Feb 27th, 2001, 03:43 AM
#8
oh...
but i have an alternative for Netscape.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|