I have a page with a menu on the left. When you click on one of the menu items, a <div> appears on the page with a movie. However, if you click a different menu item, the movie still plays even though the div is replaced by a different div. Is there a way to stop the movie from playing in the first div once a different menu item is clicked? Here’s the code:
<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(‘d1’);”></a>
<div id=”d1″ style=”display:none”><embed src=moviefile></embed></div>