Results 1 to 4 of 4

Thread: Sound Effects

  1. #1
    Join Date
    Jul 2008

    Sound Effects

    Hi everybody, i want to place a sound effect into the mouseover of an anchor link, how is this done?
    Ive tried this but its obviously wrong:
    HTML Code:
    <a href="pagename.html" onmouseover="this.src'soundeffects/wine_glass_1.wav'>blah</a>
    Thats was purely a guess to see if it works which it doesn't however do i need some sort of audio player installed in the site/server in order for it to work?
    This is purely cosmetic and and in no way adds to the site functionality however i just want to tart up the anchor links a little

  2. #2
    Join Date
    May 2004
    Moved to better forum.

    ""Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."" -- Sir Winston Churchill

  3. #3
    Join Date
    Feb 2008
    I take a dual approach to supporting sound in a web page. The reason is because IE works best if you use its proprietary BGSOUND tag. So, place this in the HEAD section of your page:
    HTML Code:
    <bgsound id="ieSound" src="#" loop="1">
    Then, since other browsers will basically ignore that, place this at the bottom of your page's BODY section for later use:
    HTML Code:
    <div id="nnSound"></div>
    Lastly, use this JavaScript function to play a specified sound file:
    var player = null;
    function playSound(url, mime) {
        if (!player) {
            if (document.all
            && document.all["ieSound"]
            && document.all["ieSound"].src)
                 player = document.all["ieSound"];
            else player = document.getElementById("nnSound");
        mime = mime || "audio/wav";
        if (player.src) player.src = url;
        else player.innerHTML = '<embed src="'+url+'" autostart="true" hidden="true" loop="false" type="'+mime+'">';
        return true;
    Now, other than IE, some browsers may require a plugin in order to play sound files. When in doubt, be sure to pass the second argument to the function to specify the correct MIME type for the particular sound file you're trying to play.
    Last edited by MrNobody; 11-21-2008 at 06:29 PM.

  4. #4
    Join Date
    Jul 2008
    Thank you very much for that.

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