www.webdeveloper.com
Results 1 to 7 of 7

Thread: Adding sound to buttons and links

  1. #1
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367

    Question Adding sound to buttons and links

    Hi,
    can anyone show me the code i need to add sound to a button and/or a link?
    ----------------------------------

  2. #2
    Join Date
    Feb 2003
    Location
    Britain
    Posts
    1,335
    That depends on what you want it to do. If all you want is to link to a sound, you can use HTML, whereas if you want, say, to play a sound for a few seconds then load a new page, you need JavaScript. Which will it be?

  3. #3
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    play for a few seconds then load new page
    ----------------------------------

  4. #4
    Join Date
    Feb 2003
    Location
    Britain
    Posts
    1,335
    Always the same music, or different music for different links?

  5. #5
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    HI,
    more of a checkout sound playing for a few seconds when the user clicks a button called add to cart
    ----------------------------------

  6. #6
    Join Date
    Feb 2003
    Location
    Britain
    Posts
    1,335
    Here's what you need:

    Put this in the head of the document:
    Code:
    <script type="text/javascript">
    <!--
    function playango(togo) {
    go=togo;
    window.setTimeout("document.location.href=go",2000);
    document.embeds['0'].play();
    }
    // -->
    </script>
    Then put this in the body, replacing the src of it with the source of your music:
    <embed src="yourtune.wav" hidden=true autostart=false>

    Then link to your add to cart page like this:
    Code:
    <a href="cart.html" onclick="playango('cart.html');return false; ">Add to Cart</a>
    Making sure that you put the new URL in the href AND the brackets in playango().

  7. #7
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    Great! will try that thanks
    ----------------------------------

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles