All Hail the New standards

With the move by later browsers to support a more standard DOM we can replace both bits of code with

document.getElementById('picture').style.visibility='hide'

document.getElementById() is the new and cross browser way to access any element on a web page by its id attribute.

Note the case of the letters in getElementById

This code works for Firefox, Netscape 6+, IE 5+ and any other DOM compliant browser.
It will not work in Netscape 4 or IE4 however.
If that is a concern use the older code, but remember Netscape 4 has less than 2% of the browser market.

New DOM example Try this example which works in both IE5+ and Netscape 6+ then view the code

Here is the code
<head>  
<title>Mike Capstick's new hide and show example</title>
<script type='text/javascript'>  
<!--  
function hideme(){ 
	if (document.getElementById('graphic').style.visibility=='hidden')
		{document.getElementById('graphic').style.visibility='visible';}
	else 	{document.getElementById('graphic').style.visibility='hidden';}  
}  
//-->  
</script>  
</head>  
<body style='text-align:center;background-color:#eeffee;'>  
<div  style='position:relative;' id='graphic'><img src='rose.gif' alt='rose' /></div>  
<form action=''>  
<input type ='button'  value='hide/show' onclick='hideme();' />  
</form>  
</body>