Page 2 of 2

Populate data into new window

Posted: Tue Apr 14, 2015 2:41 am
by Hawk

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!


Populate data into new window

Posted: Wed Apr 15, 2015 3:55 am
by Yurii Orishchuk

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


Populate data into new window

Posted: Tue May 12, 2015 9:45 am
by Hawk

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.


Populate data into new window

Posted: Mon Mar 07, 2016 2:25 pm
by Crish _

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.


Populate data into new window

Posted: Tue Mar 08, 2016 10:44 am
by Hawk

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


Populate data into new window

Posted: Tue Mar 08, 2016 4:41 pm
by Crish _

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