Why does this code cause the page to scroll to the top? It doesn’t reload the page, but when I click a thumbnail to be viewed in the picture viewer on the right, the page automatically goes to the top even though the thumbnails and picture viewer are in the middle of the page? Thanks:
<script> var element_id = “”;
var state = 0;
function open_close ( id ) {
if ( state == 0 ) {
state = 1;
element_id = id;
document.getElementById( id ).style.display = ‘block’;
} else {
if ( id == element_id ) {
// state = 0;
// document.getElementById( id ).style.display = ‘none’;
} else {
state = 1;
document.getElementById( element_id ).style.display = ‘none’;
document.getElementById( id ).style.display = ‘block’;
element_id = id;
}
}
}
</script>
<a href=”#” onClick=”open_close(‘d28’);”><img src=”image” height=”100″ width=”100″ alt=”” border=”0″ hspace=”0″ /></a>
<div id=”d28″ style=”display:none”><img src=”image” /><br /></div>