www.webdeveloper.com
Results 1 to 10 of 10

Thread: Add Sound to mouse overs

  1. #1
    Join Date
    Dec 2002
    Location
    Saint Louis , Missouri
    Posts
    157

    Arrow Add Sound to mouse overs

    I already got the mouseover script for javascript now all i need to know is how to add sound to it (Look At File !)
    Attached Files Attached Files
    Many people already feared the staff because they banned there *** !

  2. #2
    Join Date
    Nov 2002
    Posts
    631
    What if you did:

    <head>
    <script language="JavaScript" type="text/JavaScript">

    img1 = new Image(height, width);
    img1.src = "img1.ext";
    img2 = new Image(height, width);
    img2.src = "img2.ext";

    </script>
    </head>
    <body>
    <a href="nowhere.html" onMouseOver="document.image1.src = 'img2.ext';playSound('file.wav', '1');" onMouseOut = "document.image1.src = 'img1.ext';playSound('quiet.wav', '1');"><img name="image1" src="img1.ext"></a>

    <script language="JavaScript" type="text/JavaScript">

    function playSound(file, loop);
    document.writeln("<bgsound src=\"" + file + "\" loop=\"" + loop + "\">");
    return true;
    }

    </script>
    </body>

  3. #3
    Join Date
    Dec 2002
    Location
    Saint Louis , Missouri
    Posts
    157

    Post

    I found something like that in the HTMl book i had it had the following code

    <HTML><HEAD><TITLE>Llumi's big cat dreams<TITLE>

    <SCRIPT LANGUAGE="javascript">

    <!--

    littlecat = new image(143,83)
    littlecat.src = "Real.jpg"
    bigcat = new image(143,83)
    bigcat.src = "dream.jpg"

    // -->

    </script></head></body>

    Point at Llumi to see what she's thinking.

    <a href="nowhere.html"
    Onmouseover = "document.catpic.src = bigcat.src"
    Onmouseout = "document.catpic.src = littlecat.src">

    <img src="real.jpg" name="catpic" width=143 height=83>

    </a>

    </body><html>

    Thats how it showed it in my book but it never worked !
    Many people already feared the staff because they banned there *** !

  4. #4
    Join Date
    Dec 2002
    Location
    Saint Louis , Missouri
    Posts
    157
    Originally posted by Zach Elfers
    What if you did:

    \
    /

    function playSound(file, loop);
    document.writeln("<bgsound src=\"" + file + "\" loop=\"" + loop + "\">");
    return true;
    }

    </script>
    </body>
    i was just wondering why you need all those "\" ?
    Many people already feared the staff because they banned there *** !

  5. #5
    Join Date
    Nov 2002
    Posts
    421
    document.writeln("<bgsound src=\"" + file + "\" loop=\"" + loop + "\">");
    I have not tried the whole script to see if the idea works, but I do know that bgsound only works in IE.

  6. #6
    Join Date
    Dec 2002
    Location
    Saint Louis , Missouri
    Posts
    157
    Originally posted by Zach Elfers
    What if you did:

    <head>
    <script language="JavaScript" type="text/JavaScript">

    img1 = new Image(height, width);
    img1.src = "img1.ext";
    img2 = new Image(height, width);
    img2.src = "img2.ext";

    </script>
    </head>
    <body>
    <a href="nowhere.html" onMouseOver="document.image1.src = 'img2.ext';playSound('file.wav', '1');" onMouseOut = "document.image1.src = 'img1.ext';playSound('quiet.wav', '1');"><img name="image1" src="img1.ext"></a>

    <script language="JavaScript" type="text/JavaScript">

    function playSound(file, loop);
    document.writeln("<bgsound src=\"" + file + "\" loop=\"" + loop + "\">");
    return true;
    }

    </script>
    </body>
    But won't you need to make the images with the script like document.img.src=".ext." ?
    Many people already feared the staff because they banned there *** !

  7. #7
    Join Date
    Nov 2002
    Location
    Auburn, AL
    Posts
    9,224
    <A HREF="YourPage.html" onMouseOver="playSound(0)" onMouseOut="stopSound(0)">Move mouse over to play sound</A>

    your link

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


    var aySound = new Array();

    aySound[0] = "laser.wav";


    document.write('<BGSOUND ID="auIEContainer">')
    IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
    NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
    ver4 = IE||NS? 1:0;
    onload=auPreload;

    function auPreload() {
    if (!ver4) return;
    if (NS) auEmb = new Layer(0,window);
    else {
    Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
    document.body.insertAdjacentHTML("BeforeEnd",Str);
    }
    var Str = '';
    for (i=0;i<aySound.length;i++)
    Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
    if (IE) auEmb.innerHTML = Str;
    else {
    auEmb.document.open();
    auEmb.document.write(Str);
    auEmb.document.close();
    }
    auCon = IE? document.all.auIEContainer:auEmb;
    auCon.control = auCtrl;
    }
    function auCtrl(whSound,play) {
    if (IE) this.src = play? aySound[whSound]:'';
    else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
    }
    function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
    function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }
    //-->
    </script>


    I just saw this on another site. Ok it will play a sound 'lazer.wav' whenver you roll a mouse over a link with the event handler code in it. It also preloads these sounds.
    Its pretty nifty give it a try. You should just be able to combine your event handlers though to get the desired affect with an image roll over too though.
    Last edited by PeOfEo; 06-20-2003 at 10:48 PM.

  8. #8
    Join Date
    Dec 2002
    Location
    Saint Louis , Missouri
    Posts
    157
    Originally posted by PeOfEo
    <A HREF="YourPage.html" onMouseOver="playSound(0)" onMouseOut="stopSound(0)">Move mouse over to play sound</A>

    your link

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


    var aySound = new Array();

    aySound[0] = "laser.wav";


    document.write('<BGSOUND ID="auIEContainer">')
    IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
    NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
    ver4 = IE||NS? 1:0;
    onload=auPreload;

    function auPreload() {
    if (!ver4) return;
    if (NS) auEmb = new Layer(0,window);
    else {
    Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
    document.body.insertAdjacentHTML("BeforeEnd",Str);
    }
    var Str = '';
    for (i=0;i<aySound.length;i++)
    Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
    if (IE) auEmb.innerHTML = Str;
    else {
    auEmb.document.open();
    auEmb.document.write(Str);
    auEmb.document.close();
    }
    auCon = IE? document.all.auIEContainer:auEmb;
    auCon.control = auCtrl;
    }
    function auCtrl(whSound,play) {
    if (IE) this.src = play? aySound[whSound]:'';
    else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
    }
    function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
    function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }
    //-->
    </script>


    I just saw this on another site. Ok it will play a sound 'lazer.wav' whenver you roll a mouse over a link with the event handler code in it. It also preloads these sounds.
    Its pretty nifty give it a try. You should just be able to combine your event handlers though to get the desired affect with an image roll over too though.

    http://net4tv.com/voice/Story.cfm?storyID=3413 i found another way to do a sound mouse over there !
    Many people already feared the staff because they banned there *** !

  9. #9
    Join Date
    Nov 2002
    Location
    Auburn, AL
    Posts
    9,224
    that doesnt pre-load though There are three or four similar but different methods you can use I guess. Similar but bifferent... I guess thats a new peoism right there lol similar but different.

  10. #10
    Join Date
    Jan 2006
    Posts
    1

    Question mouse over sound

    Hi there !!

    can someone please help me do a mouse sound over for my avatar.
    i am not the best of computer literate but know little bits from seing other work on it !

    my avatar is a boy on a trike(3 wheeler) doing a drift slide and would like it to have sound if my friends move their mouse over it like tires squeling !!

    could you please help me or do something with it and i could link it to my club site ?

    tis is the avatar as i got on this site.
    http://i21.photobucket.com/albums/b2...max9/av-34.gif

    thanks and could you please respond to me vai email at littlemax9@yahoo.com

    regards
    Pieter
    Last edited by JohnnyGT; 01-30-2006 at 12:56 AM.

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