Go Premium for a chance to win a PS4. Enter to Win


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
  • 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 - http://www.ora.com

I get the rest of my script info from http://developer.netscape.com


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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

886 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