Autologin with Inappbrowser on an external website?

后端 未结 1 1215
野性不改
野性不改 2021-01-23 18:05

I\'ve built a native app with Phonegap Build. Is there a way to autologin in webview on an external website (embedded with inappbrowser).

The app starts and then the us

相关标签:
1条回答
  • 2021-01-23 18:27

    Yes, it should be possible. You just need to connect proper handler to loadstop event and then use local storage to store the usernames and passwords once submit is hit and if already existing, auto-fill them.

    function loadStopped() {
        // Here use JavaScript to manipulate the actual page on hand.
        // Can't really give better description about what to do, but something like this:
        var username = "";
        if (localStorage.getItem("username") !== null) {
            username = localStorage.getItem("username");
        }
        var password = "";
        if (localStorage.getItem("password") !== null) {
            password = localStorage.getItem("password");
        }
        document.getElementById("username_field").value = username;
        document.getElementById("password_field").value = password;
        // document.getElementById("the_form").submit();
        document.getElementById("the_form").addEventListener("submit", function() {
            localStorage.setItem("username", document.getElementById("username_field").value);
            localStorage.setItem("password", document.getElementById("password_field").value);
        });
    }
    ref = window.open('http://google.com', '_self', 'location=yes');
    ref.addEventListener('loadstop', loadStopped);
    
    0 讨论(0)
提交回复
热议问题