Pass data to the inAppBrowser

Hello there again,

I need to pass some data ( Login-Name and Password ) to some website, which I open with the inAppBrowser.

I save the data before into the IOS - keychain.

When I open the inAppBrowser via a button, the first page, which is shown is this login page. At the 2 fields, i want to insert the data from the keychain.

Is it possible to do that? And if it is, how do I do?
I’m using ionic v2.

Thank you in advance

If you can use iframes can easily do this with Jquery

I can’t use iframes…

I even can’t do any changes to the web page

Maybe this way?

var pageContent = '<html><head></head><body><form id="loginForm" action="YourPostURL" method="post">' +
'<input type="hidden" name="key1" value="' + YourValue1 + '">' +
'<input type="hidden" name="key" value="' + YourValue2 + '">' +
'</form> <script type="text/javascript">document.getElementById("loginForm").submit();</script></body></html>';
var pageContentUrl = 'data:text/html;base64,' + btoa(pageContent);

var browserRef = window.cordova.InAppBrowser.open(
    pageContentUrl ,
    "_blank",
    "hidden=no,location=no,clearsessioncache=yes,clearcache=yes"
);
2 Likes

Good morning,

I tried it, but well, all it does for me is to open my login page, but nothing more :confused:

edit

I take back anything I said…
Just had a typo…

But thank you for now

Thank you this solution works for me on an android device ,only on real device with a compiled APK . It does not work in browser dev tools simulator as inapp browser is missing and the window.open fallback does not seem to open the base64 data url.
I can not get it to work on IOS (testing with Ionic Dev app ) . It opens the inapp browser but it it empty page and does not send anything
Anyone any idea why it does not work on IOS?
Thanks

Yes, I tried this and it worked…