0

Here's a JQuery UI dialog containing a very basic login form:

var dlg = $('\
  <div>\
    <form action=/dummy>\
      <p><input name=username type=text></p>\
      <p><input name=password type=password></p>\
      <p><input type=submit value="Log in"></p>\
    </form>\
  </div>\
');

dlg.dialog({
    closeText: 'cancel',
    hide: 'fade',
    modal: true,
    close: function()
    {
        dlg.remove();
    }
});

(jsFiddle)

Firefox offers to save the details when I press the button, but does not later use the saved details in any way. How can I convince Firefox to fill them in?

I tried using the techniques mentioned in this question but they didn't seem to help.

Community
  • 1
  • 1
Roman Starkov
  • 59,298
  • 38
  • 251
  • 324
  • 1
    The form needs to be present on the page before it loads. Dynamically inserted inputs don't work. Did you try some iframe [as in this answer](http://stackoverflow.com/a/4795376/27862)? – user123444555621 May 03 '12 at 15:15
  • I'm only guessing, but perhaps it won't populate the password because the controls on the dialog don't actually exist when the page is loaded-- only after the dialog function is called. It may make sense from a security standpoint that hidden or dynamically created controls wouldn't be populated. – Mike Evans May 03 '12 at 15:28

1 Answers1

2

I updated your jsFIddle: http://jsfiddle.net/nfhp9/5/

It's basically happening because the form does not exist on page load and firefox enters the info when the page loads.

Dan Barzilay
  • 4,974
  • 5
  • 27
  • 39
  • This is odd... Never thought it needs to exist on load - after all, if you change the user name, the password gets substituted with a different one! So if I want the login form to be a popup, I have to serve it on every single pageview, hidden?... – Roman Starkov May 03 '12 at 15:34
  • looks like it.. or you can save the username and password using javascript and not firefox and than load it on every page... – Dan Barzilay May 03 '12 at 16:45
  • 1
    In case anyone else stumbles across this post... Other people have solved this by dynamically creating an iframe within the pop-up. At least in Firefox, if the password box is inside the newly created iframe, it will get populated. One of the benefits is that the master password, if set, won't be prompted for until you click "Log in". – Roman Starkov Mar 18 '13 at 18:15