Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Nov 2002
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Making a sound when i link is clicked.

    is it possible to play a sound when a link is clicked?

    thx alot

    -Mars
    A computer is like air conditioning...open windows and it stops working.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    -27° 28' 22" , 153° 1' 22"
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use the code below and it should work fine for you.

    Remember to link the src="" to the sound file you want to play.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
    <title>Untitled</title>
    <head>
    <SCRIPT LANGUAGE=JavaScript>
    function playSound(){
    document.music.play();
    }
    </SCRIPT>
    </head>
    <body>
    <EMBED SRC="sound file" autostart=false HIDDEN=TRUE NAME="music" MASTERSOUND>
    <a href="#null" onclick="playSound();return false">PUT YOUR LINK HERE TO PLAY SOUND</a>
    <input type="button" value="Stop music" onclick="music.stop()">
    </body>
    </html>

    Edit: ADDED STOP BUTTON TO CODE
    Last edited by JustAsking; 11-05-2002 at 05:59 AM.
    "Computers are considered female - As soon as you make a commitment to one, you find yourself spending half your paycheck on accessories for it."

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Always put an 'off' button/link in your page in case your visitor doesn't like your 'wonderful' muzik/sounds.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    -27° 28' 22" , 153° 1' 22"
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Amended code above with stop button!!!
    "Computers are considered female - As soon as you make a commitment to one, you find yourself spending half your paycheck on accessories for it."

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    United Kingdom Confused: Often
    Posts
    859
    Thanks
    0
    Thanked 0 Times in 0 Posts
    heres a script for onmouseover... could be easily changed to onclick, although... if the link is to another page the user will be gone before they can enjoy it...

    http://www.javascriptkit.com/script/...oundlink.shtml

    redhead

  • #6
    New Coder
    Join Date
    Nov 2002
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thx

    thx a lot for your replies
    A computer is like air conditioning...open windows and it stops working.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •