View Full Version : midi won't play

12-23-2006, 11:27 PM
code from page: http://www.alwaysalady.net/gwain/gwain.html

I know there is something very simple I'm missing, *sigh*, and I'm tired of looking soooo...I'm "going to the experts". :D

So will some wonderful, kind and knowledgable person :p (flattery always helps), help me out, pretty, pretty please???

var musicsrc="../midis/fantasy.mid"
if (navigator.appName=="Microsoft Internet Explorer")
document.write('<bgsound src='+'"'+musicsrc+'"'+' loop="infinite">')
document.write('<embed src=\"'+musicsrc+'\" hidden="true" border="0" width="20" height="20" autostart="true" loop="true">')

Arty Effem
12-24-2006, 01:42 AM
code from page: http://www.alwaysalady.net/gwain/gwain.html
It does play - you must have a browser/plugin/hardware issue.

Here's a recommended enhancement:

<SCRIPT type='text/javascript'>
var musicsrc="../midis/fantasy.mid"

if (navigator.appName=="Microsoft Internet Explorer" && typeof window.pageXOffset=='undefined')
document.write('<bgsound id="muz" src='+'"'+musicsrc+'"'+' loop="infinite">')
document.write('<embed id="muz"src=\"'+musicsrc+'\" hidden="true" border="0" width="20" height="20" autostart="true" loop="true">');

var embedObj=document.getElementById?document.getElementById('muz'):document.all?document.all('muz'):nul l;

if(embedObj && document.body.removeChild)
document.write("<A HREF='#' onclick='document.body.removeChild(embedObj);return false'><B>KILL MUSIC STONE DEAD<\/B><\/A>");

12-24-2006, 02:28 AM
You donít need JavaScript for this. You may as well use the correct method of calling a MIDI file for standard‐compliant browsers as well. The below code was tested in Firefox 2, Internet Explorer 6/7, and Opera 9.

<!--[if IE]>
<bgsound src="sound.mid" loop="infinite"/>
<object width="0" height="0" type="audio/midi" data="sound.mid">
<param name="loop" value="true"/>

The above code will leave a dot in Internet Explorer. If you find it problematic, you can get rid of the dot by using another conditional comment (http://www.quirksmode.org/css/condcom.html) to set the object elementís display property to none for that browser.

12-24-2006, 06:32 AM
:confused: don't know why, but the original code works now.....go figure!!

Thanks guys soooo much for your help, you're AWESOME!!!!