Effective Embedded Sounds, Avoiding ActiveX
ALL OF THE FOLLOWING JAVASCRIPT AND HTML ABOUT EMBEDDED SOUNDS SEEMS TO WORK ON ALL PLATFORMS AND JUST ABOUT ALL BROWSERS, AS LONG AS JAVASCRIPT AND SOUNDS ARE TURNED ON (BUT SEE FIREFOX NOTE).
<script src="sound.js"></script>
The above code in the HEAD tag, as well as the inline code and .js file contents below, are needed for sounds to occur with the least hassle. The above code loads an external .js file with a Javascript function in it. The idea is to avoid an ActiveX control from running in Internet Explorer during sound routine calling. If the function is embedded in the page's code rather than external, it will put this nasty and unappreciated ActiveX control in the user's face for him to click on. Avoid this!
Use this inline HTML code wherever sounds are needed:
<span id="a1"></span><form><input type="button" value="sound name" onClick="sound('sound-name.mp3','a1')"></form>
The sound.js file has only the Javascript function below in it. Remember to leave out the SCRIPT tags. Note that it uses the DHTML trick of using innerHTML to modify the page code so that it has sound in it, which lets you avoid having sound files load when the page loads as well as being part of the ActiveX avoidance strategy. The embedded sound will be inserted invisibly between the SPAN tags. Remember to convert any .wav files into .mp3 files as they are so much smaller and load a heck of a lot faster.
function sound(s,q) {document.getElementById(q).innerHTML="<embed src='"+s+"' hidden=true autostart=true loop=false>"}
Of Course, There Always Has to Be That Wiseguy Who Won't Play by the Rules and Has to Do Everything HIS Way!
Due to the fact that Firefox doesn't seem to understand the importance of either supporting video or audio as legitimate website entities, you'll find it necessary to have the following message added to every site where you utilize the strategies on this page, even though some Windows OS/computer configurations will like Firefox's audio support just fine (Vista may have Firefox audio problems but XP might not—go figure):
If you have trouble making the Sounds on this site work in Firefox, open your QuickTime player (it's free—get it if you don't have it), then select Preferences and then QuickTime Preferences. On the Browser tab, click the MIME Settings button. Make sure there is a black, not gray, checkmark on the MP3 MIME type. If, not, click on it so QuickTime is the default player for MP3. Click Apply and/or Okay and you may exit QuickTime. NOTE: If Firefox still won't work, go here, click the button that says Add To Firefox, and then restart Firefox.
Don't forget to have the following link on the word here:
<a HREF="https://addons.mozilla.org/en-US/firefox/addon/1879">here</a>