How can I get browser to prompt to save password?

前端 未结 20 1532
面向向阳花
面向向阳花 2020-11-22 16:20

Hey, I\'m working on a web app that has a login dialog that works like this:

  1. User clicks \"login\"
  2. Login form HTML is loaded with AJAX and displayed i
20条回答
  •  半阙折子戏
    2020-11-22 16:51

    I tried spetson's answer but that didn't work for me on Chrome 18. What did work was to add a load handler to the iframe and not interrupting the submit (jQuery 1.7):

    function getSessions() {
        $.getJSON("sessions", function (data, textStatus) {
            // Do stuff
        }).error(function () { $('#loginForm').fadeIn(); });
    }
    $('form', '#loginForm').submit(function (e) {
        $('#loginForm').fadeOut();
    }); 
    $('#loginframe').on('load', getSessions);
    getSessions();
    

    The HTML:

    Please log in


    getSessions() does an AJAX call and shows the loginForm div if it fails. (The web service will return 403 if the user isn't authenticated).

    Tested to work in FF and IE8 as well.

提交回复
热议问题