?
Solved

Sound on onmouseover click

Posted on 1998-11-09
2
Medium Priority
?
174 Views
Last Modified: 2008-03-10
I am wandering if s it possible to get sound with JS onmouse over click? Also, any possibility for SOUND PRELOAD?

regs
abusrbin
0
Comment
Question by:abusrbin
[X]
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
  • 2
2 Comments
 
LVL 10

Accepted Solution

by:
kollegov earned 300 total points
ID: 1273809
I have example on my page
at
http://www.geocities.com/siliconvalley/lakes/8620/soundlink.html

Here it is:
<HTML>
<HEAD>
<script>
 browserOK=false;
 laOK=false;
 midOK=false;
 wavOK=false;
 var loaded=false;
 
 
 filenames= new Array();
 filenames[0] = "passport.mid"
 filenames[1] = "chimes.wav"
 // pre-cache sounds as images.
 im0=new Image();
 im1=new Image();
 im0.src=filenames[0];
 im1.src=filenames[1];

 if(navigator.plugins["LiveAudio"])
    {browserOK=true; laOK=true;
     for(i=0;i<navigator.mimeTypes.length;i++)
       {mime=navigator.mimeTypes[i];

        // check LiveAudio enabled for WAV if you use wav
        if(mime.suffixes.indexOf("wav")!=-1)
          {if(mime.enabledPlugin==navigator.plugins["LiveAudio"])
             {wavOK=true;}
          }

        // check LiveAudio enabled for MIDI if you use midi
        if(mime.suffixes.indexOf("mid")!=-1)
          {if(mime.enabledPlugin==navigator.plugins["LiveAudio"])
             {midOK=true;}
          }
       
        // mask broserOK with midOK and wavOK
        // in case you use only 'midi', remove '&& wavOK'
        // and vice versa...
        browserOK=browserOK && midOK && wavOK;
       }    
    }
 if(navigator.javaEnabled()==false) browserOK=false;

 function playIt(n)  
 {p=canuse(n);
  if(p!=null)
   {if(p.IsReady())
     {if(p.IsPlaying()!=true)
        {p.play(false);}
     }
   }
 }

 function stopIt(n)
  {p=canuse(n);
   if(p!=null) {p.stop();}
  }
 
 function canuse(n)
  {if(browserOK==true)
     {if(eval("im"+n+".complete")==true)
       {if(loaded)
         {p=document.embeds["myplayer"+n];
          if(p.IsReady()) {return p;}
         }
       }
     }
   return null;
  }
</SCRIPT>

</HEAD>
<BODY TEXT="#00FF00" BGCOLOR="#000000" LINK="#00FFFF" VLINK="#FF00FF" ALINK="#FF0000"> onLoad="loaded=true";

<EMBED src="passport.mid"
        hidden=true
        name="myplayer0"        
        autostart=false
        MASTERSOUND>

<EMBED src="chimes.wav"
        hidden=true
        name="myplayer1"        
        autostart=false
        MASTERSOUND>

<P>
<A HREF="index1.html"
 onMouseOut="stopIt(0)"
 onMouseOver="playIt(0)"
>Try this link for .mid</A>
</P>

<P>
<A HREF="index.html"
 onMouseOut="stopIt(1)"
 onMouseOver="playIt(1)"
>Try this link for .wav</A>
</P>

</BODY>
</HTML>
0
 
LVL 10

Expert Comment

by:kollegov
ID: 1273810
I just forgot to mention that you need to have
"passport.mid" and "chimes.wav"
(files used to inialize EMBEDs) files in the same directory.
If your emebds refers to unexisting files initially
script wouldn't work :)

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
Suggested Courses

765 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