Android InAppBrowser _system callbacks

I am developing a mobile application for Android / IOS / Windows 8 in Cordoba, which needs to transfer a few lines to a web page. Unfortunately, for me the webpage does not support the TLS 1.0 protocol, which means that older versions of Android (and IOS versions) cannot open the page in their own browser.

This means that calling window.open when set to "_blank" will not load the page on any version of Android up to 16 APIs, and it is really only guaranteed for 19 APIs and higher:

window.open('https://www.libertymountain.com/login.aspx','_blank') 

My solution was to change it to "_system" instead of "_blank". This works because the phone can use the Chrome or Safari browser instead of its own browser. However, when I do this, all callbacks stop working. It just opens the page and I cannot run the script.

For example, the code below does NOT call back. It simply opens a web page:

var ref = window.open('https://www.libertymountain.com/login.aspx','_system');
ref.addEventListener('loadstart', function() { alert("Hello"); });

Am I missing something, or is there a right way to do this?

EDIT: just to be clear, this is my code that never calls the callback:

document.addEventListener("deviceready", init, false);

function init() {
    window.open = cordova.InAppBrowser.open;
    var ref = window.open('https://www.libertymountain.com/login.aspx', '_system');
    // This event never triggers, nor does any other event, even though the
    // webpage is opened in Chrome
    websiteReference.addEventListener('loadstart', function(event) { console.log('Hello'); });
}

If I changed it to this, events are activated. But I need to do this using "_system", otherwise the old Android and iOS devices will not be able to do this.

document.addEventListener("deviceready", init, false);

function init() {
    window.open = cordova.InAppBrowser.open;
    // Change '_system' to '_blank'
    var ref = window.open('https://www.libertymountain.com/login.aspx', '_blank');
    // This event never triggers, nor does any other event, even though the
    // webpage is opened in Chrome
    websiteReference.addEventListener('loadstart', function(event) { console.log('Hello'); });
}
+4
source share
2

, ( "_system" InAppBrowser window.open()). . , "_blank", , , .

+1

script , : -

var ref = window.open('http://www.libertymountain.com/','_system');
$(ref .document).load(function() {
    alert('Hello');
    // do other things
});

+ -------

document.addEventListener("deviceready", onDeviceReady, false);

// device APIs are available
//
function onDeviceReady() {
     var ref = window.open('http://www.libertymountain.com/','_system');
     ref.addEventListener('loadstart', function(event) { alert('Hello'); });
}
0

All Articles