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
Solved

Sound on onmouseover click

Posted on 1998-11-09
2
171 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
  • 2
2 Comments
 
LVL 10

Accepted Solution

by:
kollegov earned 100 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…
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…

828 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