How to stop background sound on web page?

  Chris-238213 09:45 09 Apr 06

I have a web site on my local work intranet which on opening the home page plays music using the bgsound command. All my other pages on the site open in a new window, and one of them also has music and if that page is opened before the music file in the home page has finished both music files are played at the same time which obviously sounds lousy. Is there a command in html that can be used that stops the music file in the home page playing if the link to the second music containing page is activated? If not in html is there a Java alternative?

  Aze 18:28 09 Apr 06

have a look here click here

  Chris-238213 22:10 11 Apr 06

thanks Aze, link was helpful. Actually did a bit more digging around and found some script which I modified as below and works:

<embed name="sound1" src="my music file.mp3" hidden=true loop=false autostart=true>
<script language="JavaScript"><!--
var can_play = true; var mimetype = 'audio/midi';

function playSound(idx) {
if (document.embeds && can_play) {

function stopSound(idx) {
if (document.embeds && can_play)
<a href="my web page.html" target="_blank" onclick="stopSound(1)">My web page</a>

If change autostart to false, can add additional elements to the <a href> command such as onMouseOver="playSound(1)" onMouseOut="stopSound(1)" which starts and stops the music when the mouse is moved on and off the link.

Hopefully others will find this useful

This thread is now locked and can not be replied to.

Surface Pro (2017) vs Surface Pro 4

Where HTML5 is headed next

MacBook Pro v Surface Pro 5