Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2013
    Thanked 0 Times in 0 Posts

    Question Help! Konami code with sound?

    Hmmm.... i cant seem to get this to work. I was going to use this on my homepage.

    When you correctily entered the "Konami Code" your supposed to hear a sound.

    <script type="text/javascript" src="http://konami-js.googlecode.com/svn/trunk/konami.js"></script>
    <script type="text/javascript">
        konami = new Konami()
        konami.code = function play() 
         var embed = document.createElement('object');
         embed.setAttribute('src', 'C:\Users\Willium\Music\Area Cleared.wav');
         embed.setAttribute('hidden', true);
         embed.setAttribute('autostart', true);
         embed.setAttribute('enablejavascript', true);
    So what I have done is edited the original konami code (code) from just bringing up a textbox saying you have 30 lives to playing a sound. http://www.youtube.com/watch?v=zHOPEjpMv1A

    What did i do wrong and why wont it play a sound? Mind you the src for the sound destination is only local because i am testing it first before uploading it to my server.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,848 Times in 4,809 Posts
    I don't know if this is the only problem, but...

    In JavaScript (and Java/C/C++/C#/other languages) the backslash character is used as an ESCAPE character, giving special meaning to the character it. The \n means "newline" and \t means "tab", etc.

    If the following character does not have a special meaning then then the character, alone, is the result. The backslash just disappears.

    In order to actually *GET* a backslash, then, you must use a pair of them.

    'C:\Users\Willium\Music\Area Cleared.wav'
    became just
    'C:UsersWilliumMusicArea Cleared.wav'
    so you needed
    'C:\\Users\\Willium\\Music\\Area Cleared.wav'
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by Old Pedant View Post

    In order to actually *GET* a backslash, then, you must use a pair of them.
    For paths it's better always to use forward slashes; the browser knows what to do with them.


    Tags for this Thread

    Posting Permissions

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