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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How can I get a sound to play on mouseover?

    Hello I am a total beginner when it comes to Java Scripting. I would like to know how to get a particular sound to play when I mouse over the link in this email protector script.

    The source file would be "sounds/up_beep.au"
    Code:
    <BODY>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    user = "username";
    site = "yoursite.com";
    
    document.write('<a href=\"mailto:' + user + '@' + site + '\">');
    document.write(user + '@' + site + '</a>');
    // End -->
    </SCRIPT>
    </BODY>
    Any help would be greatly appreciated.
    Last edited by Poink; 04-22-2004 at 02:12 PM.

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #3
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for replying Sad69 I visited the site you mentioned and tried what was there. Unfortunately it didn't work for me This is my whole code old and new to make what I want a little more clearer.

    Old code with two onMouseOver's one in <a href=""> tag and the other in <img=""> tag. The sounds play fine in this code:
    Code:
    <HEAD>
    <SCRIPT LANGUAGE="javaScript">
    <!-- Begin
    function makesound(soundobj){
    var thissound= eval("document."+soundobj)
        thissound.play()
    }
    // End -->
    </SCRIPT>
    </HEAD>
    
    <BODY>
    <EMBED SRC="sounds/up_beep.au" AUTOSTART="false" HIDDEN="TRUE" 
    NAME="sound1" MASTERSOUND="MASTERSOUND">
    <EMBED SRC="sounds/evac.au" AUTOSTART="false" HIDDEN="TRUE" 
    NAME="sound3" MASTERSOUND="MASTERSOUND">
    
    <P>
    <A HREF="mailto:joebloggs@mywebsite.com?subject=mysubjectmatterhere" 
    ONMOUSEOVER="makesound('sound1')" ONCLICK="makesound('sound3')">
    
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    mailbutton=new Image()
    mailbutton.src="images/down_mail.gif"
    // End -->
    </SCRIPT>
    
    <IMG SRC="images/mail.gif" ONMOUSEOVER='this.src="images/down_mail.gif"'
     ONMOUSEOUT='this.src="images/mail.gif"' STYLE="cursor:hand" WIDTH="128" 
    HEIGHT="34" BORDER="0">
    </A>
    </P>
    </BODY>
    This is my new code with the email protector script, I am so fed up with spam mail it's unbelievable. As you can see my <a href=""> tags are now in the JavaScript and I only have one onMouseOver in the <img=""> tag:
    Code:
    <HEAD>
    <SCRIPT LANGUAGE="javaScript">
    <!-- Begin
    function makesound(soundobj){
    var thissound= eval("document."+soundobj)
        thissound.play()
    }
    // End -->
    </SCRIPT>
    </HEAD>
    
    <BODY>
    <EMBED SRC="sounds/up_beep.au" AUTOSTART="false" HIDDEN="TRUE" 
    NAME="sound1" MASTERSOUND="MASTERSOUND">
    <EMBED SRC="sounds/evac.au" AUTOSTART="false" HIDDEN="TRUE" 
    NAME="sound3" MASTERSOUND="MASTERSOUND">
    
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    user = "joebloggs";
    site = "mywebsite.com?subject=my_subject_matter_here";
    document.write('<a href=\"mailto:' + user + '@' + site + '\">');
    
    mailbutton=new Image()
    mailbutton.src="images/down_mail.gif"
    // End -->
    </SCRIPT>
    
    <IMG SRC="images/mail.gif" ONMOUSEOVER='this.src="images/down_mail.gif"'
     ONCLICK="makesound('sound3')" ONMOUSEOUT='this.src="images/mail.gif"'
     STYLE="cursor:hand" WIDTH="128" HEIGHT="34" BORDER="0">
    </A>
    </BODY>
    Is their a simple way to put my source name="sound1" from the first <embed src=""> tag in the onMouseOver in my new script, like I have done with the OnClick="makesound('sound3')?

    Any help is really appreciated, thank you.

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think you need to take a second look at that link I posted. Notice how it refers to the play and stop methods? There's a link at the bottom of the page that shows you what the play and stop methods look like.

    Follow that example exactly. You don't need that embedded stuff you're doing.. I don't think so at least.

    Good luck,
    Sadiq.


  •  

    Posting Permissions

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