Controlling Sounds with JavaScript : Audio Video Sound : Development : JavaScript DHTML examples (example source code) Organized by topic

JavaScript DHTML
C++
PHP
JavaScript DHTML Home »  Development   » [  Audio Video Sound  ]   
 



Controlling Sounds with JavaScript

Please note that some example is only working under IE or Firefox.


/*
JavaScript Unleashed, Third Edition
by Richard Wagner and R. Allen Wyke 

ISBN: 067231763X
Publisher Sams CopyRight 2000

*/
<html>
<head>
  <title>JavaScript Unleashed</title>
  <script type="text/javascript">
  <!--
    function playSound(sfile) {
   
      // load a sound and play it
      window.location.href=sfile;
    }
  //-->
  </script>
</head>
<body onLoad="playSound('Type.wav')" onUnLoad="playSound('Glass.wav')">
  <h2>
    Sounds on JS Events
  </h2>
  <hr>
  The following are examples of JS event handlers used to play sounds.
  <hr>
  <a href="#" onClick="playSound('Cashreg.wav')">
    Click here for sound
  </a>

  <p>
    <form name="form1">
      <input type="button" value="Play" onClick="playSound('Gunshot.wav')">
    </form>
  </p>
</body>
</html>

           
       
Related examples in the same category
1.  Inserts an audio or video medium in the current Web pageHas Download File
2.   Accessing a Plug-In
3.  Controlling Embedded Sounds with JavaScript








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.