Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


IE4 sound playing

Posted on 1998-04-27
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 300 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

661 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