- Forums
- Javascipt
- Show And Hide Picture With Javascript
Hiding And Showing A Picture Using Javascript Code Will Show You Example Of How You Can Hide Or Show A Picture Image When You Click Ona Link [2195], Last Updated: Mon Jun 24, 2024
Webune Tutorials
Sun Dec 20, 2009
1 Comments
432 Visits
Welcome to Webune Support Forums
We provide web hosting to people just like you who are just beginning to program their websites. We provide excellent support service, that is why we have created this post to show you how you can make a picture shows when you click on a link
the best way to learn is by example, take a look a this example:
now you probably want to know who we did it, we used the following HTML, CSS and JAVASCRIPT code to make it happen
<script language="javascript">
<!--
// PLEASE DO NOT REMOVE THIS. THANKS
// FIND GREATE JAVASCRIPT CODES AT http://www.webune.com
var state = 'hidden';
function Show_Picture(layer_ref) {
if (state == 'visible') {
state = 'hidden';
}else {
state = 'visible';
}
if (document.all) { //IS IE 4 or 5 (or 6 beta)
eval( "document.all." + layer_ref + ".style.visibility = state");
}
if (document.layers) { //IS NETSCAPE 4 or below
document.layers[layer_ref].visibility = state;
}
if (document.getElementById && !document.all) {
Webune_Form = document.getElementById(layer_ref);
Webune_Form.style.visibility = state;
}
}
//-->
</script>
<!-- HIDDEN INFORMATION TO BE SHOWN ONCLICK -->
<div id="Layer1" style=" visibility:hidden;">
<img src="http://www.webune.com/images/headers/default_logo.jpg" border="0" />
</div>
<!-- END - HIDDEN INFORMATION TO BE SHOWN ONCLICK -->
<div><a href="javascript://" onclick="Show_Picture('Layer1');">Click HERE To Show and Hide Picture</a></div>
as you can see, when you click on the link, it shows or hides the picture of our logo