Results 1 to 7 of 7

Thread: Simple Javascript Problem

  1. #1
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Exclamation Simple Javascript Problem

    PULLING MY HAIR OUT!!!!
    I have TRYED to work out this bug BEFORE going to DD for help (so don't get up in my grill), because I always say to myslef "Come on, you don't need to ask for help with a problem like this". I fianly broke loose, and decided to post. When you press the button, it is suposed to open Windows Media Player and play the song that was in the address bar. It works fine with the link...
    Code:
    <html>
    <head>
    <style>
    html, body
    {
    scrollbar-face-color:#EBF5FF;
    scrollbar-base-color:#EBF5FF;
    scrollbar-arrow-color:black;
    scrollbar-track-color:#F3F3F3;
    scrollbar-shadow-color:#EBF5FF;
    scrollbar-highlight-color:#EBF5FF;
    scrollbar-3dlight-color:#78AAFF;
    scrollbar-darkshadow-Color:#78AAFF;
    }
    container
    {border:1px solid black; background-color: lightyellow;}
    </style>
    <script>
    function getQueryVariable(variable) {  
    var query = window.location.search.substring(1);  
    var vars = query.split("&");  
    for (var i=0;i<vars.length;i++) {    
    var pair = vars[i].split("=");    
    if (pair[0] == variable) {      
    return pair[1];    }  
    }  
    return "";
    }
    var song = getQueryVariable("song");
    var mp3 = getQueryVariable("mp3");
    document.title="Download: "+song;
    </script>
    </head>
    <body background="bg.jpg">
    
    <script> document.write('<form action="C:\\Documents and Settings\\Pip\\Desktop\\Bob Grawi\\'+mp3+'"><center><h2>Download '+song+'</h2></center>');</script>
    <div class="container" style="padding: 5px;">
    <script>
    document.write('<center><input type="submit" value="Download '+song+'"></center>');
    //document.write('<a href="C:\\Documents a[removed]b Grawi\\'+mp3+'">Download</a>')
    </script>
    </div>
    </form>
    </body>
    
    </html>
    HELP!
    Last edited by jscheuer1; 12-23-2007 at 08:20 PM. Reason: remove OP's possible directory structure
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    IDK, it's working for me here, though I did use an mp3 file from the web, not my hard drive. One thing I would do is unescape the query value:

    Code:
    return unescape(pair[1]);    }
    But that's just for cosmetic purposes.

    Are you sure you are feeding it a valid URL, like:

    Code:
    page.htm?mp3=web.mp3&song=Love Shuffle
    ?

    The code could be more standard, but I got the impression that you don't care about that.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I was thinking about this, and maybe being on the web has something to do with it because of the path. If you are using your local machine, perhaps you should make this:

    Code:
    C:\\Documents a[removed]b Grawi\\
    a web type path:

    Code:
    file://localhost/C:/Documents%20a[removed]b%20Grawi/
    Last edited by jscheuer1; 12-23-2007 at 08:19 PM. Reason: remove OP's possible directory structure
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Thanks! The uirl was the problem,
    BTW, This script was part of the kiosk script that I got to work!
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Just out of curiosity, was it the this type URL:

    Code:
    page.htm?mp3=web.mp3&song=Love Shuffle
    or this one:

    Code:
    C:\\Documents a[removed]b Grawi\\
    ?
    Last edited by jscheuer1; 12-23-2007 at 08:18 PM. Reason: remove OP's possible directory structure
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Sorry, I un-subscribed from this post, so I did not know you posted until now...
    The second one
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Thanks, saved me the trouble of playing around with it some more, that will earn you some free advice:

    It probably isn't a good idea to post the directory structure of your local disk in a public forum.

    Now I don't know if you actually did that or not, but it looked like you might have.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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