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 11 of 11
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Posts
    433
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question sound with javascript?

    I want to play a sound file using Javascript ....How can i do this?

  • #2
    GDS
    GDS is offline
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try something like this:

    <EMBED
    SRC="mysong.mid"
    HIDDEN=true
    AUTOSTART=true
    REPEAT=true
    height="0"
    width="0">
    <NOEMBED>
    <BGSOUND SRC="mysong.mid" loop="infinite">
    </NOEMBED>




    GDS

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    That's an excellent way to make your visitors leave immediately!.

    For Pete's sake and your visitors, don't start the muzik when they enter...and use an "On/Off" button/link, too.

    <embed id="plyr" width="0" height="0" autostart="false" loop="true" src="lol.wav"><b>

    <a href="javascript: document.getElementById('plyr').play();">start</a>

    <a href="javascript: document.getElementById('plyr').stop();">stop</a>
    Last edited by zoobie; 08-25-2002 at 10:09 PM.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #4
    New to the CF scene
    Join Date
    Nov 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am having trouble trying to use your code with netscape. Whenever I do I get the following error:

    Error: document.getElementById("plyr").play is not a function


    What am I doing wrong?

    NH

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you using Netscape 4.x ?

    Only modern browsers use getElementById(), Netscape 4.x is obsolete now.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #6
    New to the CF scene
    Join Date
    Nov 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Netscape 7.0

  • #7
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    how would you make it so that the sound playes once, and than the sound can be repeated when wanted, or changed to a different sound and repeated.
    would it just be making the loop = "false" and when the play() is used it would play it once, and play again when the play() is used again?

    this could be useful for making a game, or somekind of javascript menue that makes sound
    Kris Hubby
    kwhubby site

  • #8
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    scratch that question, I just solved it myself. (the answer is true)
    Kris Hubby
    kwhubby site

  • #9
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you using Netscape 4.x ?

    Only modern browsers use getElementById(), Netscape 4.x is obsolete now.
    I'm using IE6 ( WinXP ) and I get the same error message!

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Who dug this old thread up?
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #11
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts

    lol

    HANDS UP! IT WASN'T ME!!


  •  

    Posting Permissions

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