Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Populate data into new window

Hi Yurii,

I've used the device browser by replacing
prevar loginWindow = window.open('https://link', '_blank', 'location=yes');/pre

with
prevar loginWindow = window.open('https://link', '_system', 'location=yes')/pre

It opens Android Chrome, IE ... etc. but the codeaddEventListener/code is not firing. I've added alerts inside codewindow.addEventListener/code and codegiveMeUsername/code. None is displaying! No errors show!

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Populate data into new window

Hi Haytham,

Unfortunatly you have only two ways to open url in new window.

  1. InappBrowser.

  2. systemBrowser.

    And if you can control inAppBrowser, you will not be able to control system browser.

    You can interact with inapp browser in following way: http://blogs.telerik.com/appbuilder/p...

    Regards

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Populate data into new window

Thanks, I managed to do that following the link you posted. The following is my code for future reference for others:

pre
var username = localStorage.getItem("username");
var password = localStorage.getItem("password");
var language = localStorage.getItem("lang");
var credentials = username + '-' + password;
var msg = language + ':' + username + '-' + password;
var lan = '';
var lan_change = '1';
'location=yes');
var loginWindow = window.open('https://link', '_blank', 'location=yes,clearsessioncache=yes');
loginWindow.addEventListener('loadstop', function() {
loginWindow.executeScript({
code: "jQuery('input#username').val('" + username + "'), jQuery('input#password').val('" + password + "')"
}
);
if (language === 'en') {
loginWindow.executeScript({
code: "jQuery('#lang option[value=en-GB]').attr('selected','selected')"
});
} else if (language === 'bm') {
loginWindow.executeScript({
code: "jQuery('#lang option[value=ms-MY]').attr('selected','selected')"
});
} else if (language === 'ch') {
loginWindow.executeScript({
code: "jQuery('#lang option[value=zh-TW]').attr('selected','selected')"
});
}
if (lan_change === '1') {
loginWindow.executeScript({
code: "jQuery('#lang').change()"
});
lan_change = '0';
}
jQuery(function() {
setTimeout(function() {
loginWindow.executeScript({
code: "jQuery('.loginbtn').click()"
});
}, 5000);
});
});
/pre

The code populates the username, password into their fields in child inAppWindow, and it changes the language from selectMenu, and then clicks programmatically 'login' button in child window. This is dirty fix almost like a hack and had zero consideration for security concerns.

Crish _
Posts: 0
Joined: Mon Mar 07, 2016 2:25 pm

Populate data into new window

Hi Hawk,
This is a excellent code snippet.

One question here - After you have programatically clicked the 'login' button and the page says provides you some json data or some specific headers, How do you capture that.

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Populate data into new window

Very interesting! That something have not done though. Sorry!

Crish _
Posts: 0
Joined: Mon Mar 07, 2016 2:25 pm

Populate data into new window

:) Thanks Hawk for your kind response, grappling with this for quite some time

Return to “Issues”