View Full Version : MUSIC ON/OFF (in IE 7 doesn't stop)

05-05-2008, 01:10 PM
Hello there

I am trying to fix a bug in the following script as the music does not stop in IE 7 if the file is an .mp3 but does in IE 5 +6 and Firefox. I hope you can help. Thank you!

<script type="text/javascript">

var sound2Embed = null;

function init() {

function sound2Play() {
if ( !sound2Embed ) {
sound2Embed = document.createElement("embed");
sound2Embed.setAttribute("src", "audio/tequila.mp3");
sound2Embed.setAttribute("hidden", true);
sound2Embed.setAttribute("autostart", true);
} else sound2Stop();
sound2Embed.removed = false;

function sound2Stop() {
if ( sound2Embed && !sound2Embed.removed ) {
sound2Embed.removed = true;


<body onload="init();">

<input type="submit" onclick="sound2Play();" name="Play 2" value="Play 2">

<input type="submit" onclick="sound2Stop();" name="Stop 2" value="Stop 2">

05-05-2008, 07:40 PM
You might want to read this thread:


But you might want to read the whole thing before deciding which code to use, and as mentioned in that thread, there is always Flash. The thread is so long in terms of time, that some of the earliest code may be outdated. As I recall, I revisited that thread several times each time a user started having trouble with the code and reported it.

05-11-2008, 10:05 AM
Thanks for your reply.

Just for yuor information I have checked the thread but it does not work with .mp3 files in FF.


05-11-2008, 03:18 PM
Are you sure you used the latest version in that thread? It worked here for that:

Please post a link to the page on your site that contains the problematic code so we can check it out.