42 users online (1 members and 41 guests)  


  Results 1 to 3 of 3

Related

  1. Replies: 1
  2. Free Short Subdomains Hosting?    Forum: Web Hosting Forum
    Replies: 1
  3. Replies: 2
  1. #1
    keytone's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2011
    Posts
    11

    I want play a short .wav file when image is clicked

    Hi, I'm new to this forum and am not sure if I have the the correct one, but here is my problem.

    I want to add a short sound file such as .wav to play when an image is clicked without
    it showing the media player as a page, or if it does show the media player it should close it
    and go back to the page the image is on. Is there a way to do this.
    I'm a beginner at css, but have been using html for a while. I can't find a way to do this.
    I tried the only code I could find but it opens the media player.
    I'm in need of some guidance. John
    Here's code from the page

    <table border="0" width="100%">
    <tr>
    <td width="35%">
    <img src="/baby/baby980.jpg" border="none" align="right"></a>
    </td>
    <td width="37%">
    <center><a href="/sounds/laugh.wav"><img src="/gif/gifa/redrose180.gif" border="none"></a></center>
    </td>
    <td>
    <img src="/baby/baby1080.jpg" border="none" align="left"></a>
    </td>
    </tr>
    </table>

    Here's the page:
    http://mountaindream.freeoda.com/pages/pgtest6.html

  2. #2
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel

    Re: I want play a short .wav file when image is clicked

    Hi keytone, welcome to the forums

    From http://www.phon.ucl.ac.uk/home/mark/audio/play.htm

    Code:
    <script>
    function EvalSound(soundobj) {
      var thissound=document.getElementById(soundobj);
      thissound.Play();
    }
    </script>
    
    <embed src="success.wav" autostart=false width=0 height=0 id="sound1"
    enablejavascript="true">
    Note that we specify name of the embedded sound using its ID attribute now. The function calls however are the same as above. For example:


    Code:
    <form>
    <input type="button" value="Play Sound" onClick="EvalSound('sound1')">
    </form>
    Hope this helps

    Dave
    AHFBWEB Less customers per server, more power for you!

    Business Class Shared Hosting

  3. #3
    keytone's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2011
    Posts
    11

    Re: I want play a short .wav file when image is clicked

    Thanks very much, it's more than I could come up with. John