40 users online (1 members and 39 guests)  


  Results 1 to 2 of 2

Related

  1. Swap Image then Open Lightbox    Forum: Javascript Forum
    Replies: 0
  2. Image swap and Lightbox    Forum: Javascript Forum
    Replies: 1
  3. image swap    Forum: CSS Forum
    Replies: 1
  4. image swap with links???    Forum: Javascript Forum
    Replies: 4
  1. #1
    Ken
    Ken's Avatar
    Guest

    Post How do I swap an image for BOTH an image and a sound?

    How do I do a mouseover, that changes one image, to another and a sound effect at the same time? I need to know how to preload the images and sound too. Thanks for your time.
    KEN

  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

    Post

    Ken,

    Welcome to The Help Desk
    To give it the sound on mouseover use this code. (it will not change images though)

    Place the following in the "head" of your document. please remember to change the paths and file names.

    <script language="JavaScript">
    <!--

    function play(nOption) {
    if (nOption == 1)
    document.all.sound.src="http://www.thepathtoyour/file.mid";
    else if (nOption == 2)
    document.all.sound.src="http://www.thepathtoyour/file.wav";
    else if (nOption == 3)
    document.all.sound.src="http://www.thepathtoyour/file.mid";
    else if (nOption == 4)
    document.all.sound.src="http://www.thepathtoyour/file.wav";
    else if (nOption == 5)
    document.all.sound.src="http://www.thepathtoyour/file.mid";
    else if (nOption == 6)
    document.all.sound.src="http://www.thepathtoyour/file.wav";

    }
    //-->
    </script>

    Place the following in your body tag

    <bgsound id="sound" src="">

    Changing the number in parenthesis ( ) to correspond to what you placed within the "head"
    <img src="http://pathtoyourimage/file.jpg" onMouseOver="play(1)">

    good luck,

    Dave



Tags for this Thread