Results 1 to 3 of 3

Thread: Dynamic Javascript link

  1. #1
    Join Date
    Sep 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Dynamic Javascript link

    Hello,

    I am new to javascript and am trying to create a custom log in for my ftp site. Im trying to make a form with two fields, username and password, then create a dynamic link attached to the submit button that would utilize the browser's FTP client to log them in to the FTP site. The link should look like this:

    "ftp://[username]:[password]@domainName.com" where [username] would be the text entered in the username field and [password] the text from the password field.

    Here is how it looks now:
    Code:
    <p><form name="f" onsubmit="MM_openBrWindow">
          Username:
            <input name="u" type="text"/>      
          <br/>
          Password:
      <input name="p" type="password"/>
      <input type="button" onClick="MM_openBrWindow('ftp://')" value="login"/>
        </form></p>
        
        <script type=text/javascript>
    	-->
    	var user = document.f.u.value+("@exponentialintelligence.net");
    var pass = document.f.p.value;
    function MM_openBrWindow(theURL) { //v2.0
      window.open(theURL+var user+":"+var pass+("@exponentialintelligence.net");
    }
    //-->
    </script>
    Can anyone help me please???
    Last edited by ejohnson747; 09-27-2009 at 09:51 PM.

  2. #2
    Join Date
    Apr 2008
    Location
    San Diego, CA
    Posts
    352
    Thanks
    57
    Thanked 6 Times in 6 Posts

    Default

    Try this.

    Change:

    window.open(theURL+var user+":"+var pass+("@exponentialintelligence.net");

    To:

    window.open(theURL+user+":"+pass+"@exponentialintelligence.net");
    My site: FreshCut :)

  3. #3
    Join Date
    Sep 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    UPDATE:

    ok so i changed some things around and got the user defined variables to show up in the URL. :

    Code:
       <p><form name="f" onsubmit="MM_openBrWindow()" method="post"> 
          Username: 
            <input name="u" type="text"/>      
          <br/> 
          Password: 
      <input name="p" type="password"/> 
      <input type="submit" onClick="MM_openBrWindow()" value="login"/> 
        </form></p> 
        
        <script type=text/javascript> 
       --> 
    
    function MM_openBrWindow() { 
    if (document.f.u.value == ""){ 
       alert("Username is Required"); 
       return; 
    } 
    if (document.f.p.value == ""){ 
       alert("Password is Required"); 
       return; 
    } 
      window.open("ftp://"+document.f.u.value+":"+document.f.p.value+"@ftp.exponentialintelligence.net"); 
    } 
    //--> 
    </script>

    But now the browser's FTP client is acting funny. If I try logging in through the form, (without adding @domainName.com after the username, it automatically starts a download of a blank text document.
    But if I type the same URL (ftp://usernameassword@ftp.domainName.com)
    directly into the browser, it loads a dialog box saying my username and password are incorrect.

    If I enter the username followed by @domainName.com in this dialogue box, it will log in successfully. But If I type the same syntax (ftp://username@domainName.com:passwo...domainName.com) directly into the browser, there is an error message that says page cant be shown.

    Does anyone have any experience using a web browser to connect to and FTP server?

    (I am using the latest version of Safari but the majority of the people using this will be on IE.)

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
  •