I'm trying to get the responde body of a window opened by cordovaInAppBrowser... this is my code:
$cordovaInAppBrowser.open(LOGIN_PAGE_URL,'_blank',options);//
$rootScope.$on('$cordovaInAppBrowser:loadstart', function(e, event)
{
if(event.url.indexOf(LOGIN_CALLBACK_URL)>-1)
{
$rootScope.$on('$cordovaInAppBrowser:loadstop', function(e, event){
alert("loadstop")
$cordovaInAppBrowser.executeScript(
{ code: "document.body.innerHTML" },
function(data)
{
alert("Code Inserted Succesfully");
}
);
});
}
else
{
}
});
I don't know why but the alert("loadstop") is fired, but the alert("Code Inserted Successfully") not!
If i do
$cordovaInAppBrowser.executeScript(
{ code: "alert(document.body.innerHTML)" },
it alerts the body content correctly... I'm going crazy! Please help me! Thanks.
I had same issue and I solve it.
$cordovaInAppBrowser.executeScript
is promise and you should put callback to.then()
like: