onload music

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • danielparod
    New Member
    • Jan 2008
    • 9

    onload music

    I am trying to set up my website so that our jingle plays when you load the page, but as I am new to web development, I do not know how. I taught myself how to use Dreamweaver CS3, which means that I don't know all that much, escpecially about Javascript. Can anybody explain how to get music to play onload in terms that a newbie can understand?

    Thanks,
    Daniel
  • Death Slaught
    Top Contributor
    • Aug 2007
    • 1137

    #2
    Here's a script I got 133 days ago from acoder :).

    [CODE=javascript]function play() {
    embed = document.create Element("embed" );
    embed.setAttrib ute("src", "soundfile.wav" );
    embed.setAttrib ute("hidden", true);
    embed.setAttrib ute("autostart" , true);
    document.body.a ppendChild(embe d);
    }
    [/CODE]



    Just change the part the says 'soundfile.wav' to source of your sound file. And just in case you don't know where to put JavaScript you could do it like this.


    [HTML] <head>
    <script type="text/javascript" src="script.js" ></script>
    </head>


    <body onload="play()" >
    </body>
    [/HTML]

    And save the JavaScript in it's own file name 'script.js'.

    ^_^ Hope it helps, Thanks, Death

    Comment

    • danielparod
      New Member
      • Jan 2008
      • 9

      #3
      Death,

      Thanks, I really appreciate it. I saw your thread, but I didn't really understand what I should do with it. You have cleared it up for me.

      Thanks,
      Daniel

      Comment

      • danielparod
        New Member
        • Jan 2008
        • 9

        #4
        I have a new problem, now. I put the script in my site, tested it in a couple of browsers, and it worked fine. Uploaded the new page to my site, and it doesn't work. Any ideas?

        Thanks,
        Daniel

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Post the page code. Have you linked to any script files that you forgot to upload?

          Comment

          • danielparod
            New Member
            • Jan 2008
            • 9

            #6
            Originally posted by acoder
            Post the page code. Have you linked to any script files that you forgot to upload?
            Thanks, I found it. Stupid mistake on my part. I appreciate it.

            Daniel

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Glad to hear that you managed to fix it.

              Comment

              • jay1024
                New Member
                • Feb 2008
                • 1

                #8
                I am using this code and am having a problem with it. I use exactly what is posted earlier and can't get it to work in Firefox. Any ideas? Thanks

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Originally posted by jay1024
                  I am using this code and am having a problem with it. I use exactly what is posted earlier and can't get it to work in Firefox. Any ideas? Thanks
                  Welcome to TSDN!

                  Do you get any errors? Post a test link if you have one available.

                  Comment

                  Working...