IE4 sound playing

Posted on 1998-04-27
Last Modified: 2008-02-01
I have set up a web page that both changes an image and plays a sound on the onMouse over event! This is great in Netscape 3+4. for IE3 I have a seperate page with just an animated gif and background sound. The html page has a script that senses the browser type and loads the apprpriate page. my problem lies with IE4. This works fine with the images but has problems playing the sound. Javascript errors occur.

The problem probably is to do with the way I am declaring the sound files to play i.e. with the embed tag.

what can I do to get this working, preferably one page for netscpae & IE4.

The script I am using is:

function MM_controlSound(sndAction,sndObj) {
      if (eval(sndObj) != null) {
        if (sndAction == 'stop') eval(sndObj+'.stop()'); //stop, else play
        else     eval(sndObj+((navigator.appName=='Netscape')?'.play(false)':'.run()'));

I am declaring the sound file with:
<embed name="controlS1" src="trump1.mid" loop="false" autostart="false"
mastersound="mastersound" hidden="true" width="0" height="0">

and calling on the onMouseover event handler:
<a href="about_boliden.htm"
    onMouseOver="top1.src=fade1.src, MM_controlSound('play','document.controlS1')"
    onMouseOut="top1.src=reappear1.src, MM_controlSound('stop','document.controlS1')"><img
    src="aboutb1.JPG" border="0" WIDTH="157" HEIGHT="57"></a>

Another problem I am having occurs when there is no sound card in machine under netscape 3(at least, havent tested in others) every time I move mouse over graphic to play sound it gives an error saying unable to initialise midi etc. I can in at least in IE4 call window.onerror =
noerror which will get rid of this problem.

any help appreciated,

Question by:hboys
  • 3
  • 2

Author Comment

ID: 1271515
P.S any good Javascript books that you can recommend?which can be  got on the internet.


LVL 75

Accepted Solution

Michel Plungjan earned 100 total points
ID: 1271516
This seems to be the current solution:

Navigator:  <EMBED NAME="sound" SRC="noise.wav" HIDDEN="TRUE"


Explorer:  <OBJECT ID="sound" WIDTH="0" HEIGHT="0"
           <PARAM NAME="FileName" VALUE="noise.wav">
           <PARAM NAME="PlayCount" VALUE="1">
           <PARAM NAME="AutoStart" VALUE="0">
           <PARAM NAME="ShowControls" VALUE="0">
           <PARAM NAME="ShowDisplay" VALUE="0">



The book I have enjoyed the most is Flanagan's JavaScript, The definitive Guide -

I get the rest of my script info from


Author Comment

ID: 1271517

Thats half the question answered but is there any way that I can either disable the "unable to initialise Midi" error or check via javascript if the computer has a sound card fitted so that I can load an alternative page?

LVL 75

Expert Comment

by:Michel Plungjan
ID: 1271518
There are several but they are not 100%

1.I cannot remember where the message is coming from (I have had sound cards since 1990) but if it is issued by javascript, you can do an
window.onerror = null;
in Netscape 3+ and MSIE 4.

2. Look through the navigator.plugins array to see if a player is available - only works in netscape and you will need to know which players are out there
This is assuming that the user will not have installed a midi player if he/she did not have a sound card.

3. Use a java applet, but that would be a question in another section.

If this is not enough, please reopen your second question


Author Comment

ID: 1271519
cheers Michel,

Good question answer in the first part so I'll give you all the points anyway.

Not sure wether its a plugin problem as its just trying to play a sound on a machine without a sound card. I'll open it as a seperate question.



Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now