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

    background music script

    I have a problem with this code :
    <head>
    <script language=javascript type="text/javascript">
    function playSound()
    {document.muzyka.play(false)}
    function pause()
    {document.muzyka.pauseSound()}
    function stop()
    {document.muzyka.stopSound()}
    </script>
    </head><body>
    <embed src="mySound.wav" hidden=true autostart=false name="muzyka"
    mastersound><p>
    <form>
    <input type="button" value="play" onClick="playSound()">
    <input type="button" value="pause" onClick="pauseSound()">
    <input type="button" value="stop" onClick="stopSound()">
    </form>
    </body></html>


    and control panel (play, pause, stop) doesn't work. When i delete "hidden" i can listen to my sound file but my control panel still doesn't work. What's wrong? Where is an error?
    Last edited by montana; 06-03-2006 at 03:17 PM.

  • #2
    New Coder
    Join Date
    Apr 2006
    Location
    At a place
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    Code:
    <script type="text/javascript">
    function playSound()
    {document.muzyka.play(false);}
    function pauseSound()
    {document.muzyka.pauseSound()}
    function stopSound()
    {document.muzyka.stopSound()}
    </script>
    Delete the part in blue. Because when you click the "play" button, it performs the fuction playsound() but in the code it says it's "false" (you only need the value "false" in the HTML). As for "stopSound()" and "pauseSound()". They aren't real functions.

    Code:
     
    <form>
    <input type="button" value="play" onClick="playSound()">
    <input type="button" value="pause" onClick="pauseSound()">
    <input type="button" value="stop" onClick="stopSound()">
    </form>
    Be sure to delete these blue parts as well.
    Last edited by v777tony; 06-03-2006 at 10:32 PM.
    Uhh... Yeah Sure.

  • #3
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    many thanks for your advice, but it still doesn't work. Maybe there is sth wrong with my browsers? Any suggestions?
    best regards

  • #4
    New Coder
    Join Date
    Apr 2006
    Location
    At a place
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    I checked the code myself so, it should work. But just follow the below instructions.

    Make sure that other scripts aren't messing it up. Use the return(); function at the end of your scripts to prevent this (most of the time). Make sure the filepath is correct including extensions. Check code for typos. I don't know if it's your browser or not. But if it is, I recomend getting IE6(best browser ever). I also hear that IE7 it coming out also.

    Also, make sure the script is in the right place. Oh, and don't use doctypes, they're useless.

    Last edited by v777tony; 06-06-2006 at 08:58 PM.
    Uhh... Yeah Sure.

  • #5
    New Coder
    Join Date
    Apr 2006
    Location
    At a place
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by v777tony
    Don't use doctypes, they're useless.
    When I say "Don't use doctypes". I say this because the browser default is ussually better. You just have to know how to work things.
    Uhh... Yeah Sure.

  • #6
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,627
    Thanks
    0
    Thanked 648 Times in 638 Posts
    Quote Originally Posted by v777tony
    When I say "Don't use doctypes". I say this because the browser default is ussually better. You just have to know how to work things.
    What absolute nonsense. That statement is completely backwards. The browser default will definitely be WORSE because each browser default is different and so you end up with 10000+ different versions of your page only one of which might be okay.

    The DOCTYPE is one of the most important parts of the page because by using a strict DOCTYPE and making sure the page validates to that DOCTYPE you ensure that all browsers will treat the page the same way. Without a DOCTYPE each browser will do its own thing and your page will look like garbage in at least some and probably most browsers.

    There is no such tag as <embed> and so most browsers will ignore it completely. The <object> tag is for embedding ovjects into web pages.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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