How to stop background sound on web page?

  Chris-238213 09:45 09 Apr 06
Locked

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:

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

function playSound(idx) {
if (document.embeds && can_play) {
document.embeds["sound"+idx].play();
}
}

function stopSound(idx) {
if (document.embeds && can_play)
document.embeds["sound"+idx].stop();
}
//--></script>
<a href="my web page.html" target="_blank" onclick="stopSound(1)">My web page</a>
</body>

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.

Nintendo Switch review: Hands-on with the intuitive modular console and its disappointing games…

1995-2015: How technology has changed the world in 20 years

This abstract video touches on division in our technologic world

Best alternatives to iTunes for Mac | Best music players for macOS: Free your music from the…