ngCordova InAppBrowser executeScript callback not firing

Hi all,
I’m not able to get working the callback function for executeScript.
This is the code
{code: “alert(‘hello’)”},
function (values) {
The code:alert(‘hello’) is fired, so I got ‘hello’, but not the console log ‘callback’ (tried also with an alert)
Doing some debug, I saw that the part of the code where the callback should be executed is in cordova.js

msgs is ‘undefined’, and not equal to ‘@Null arguments’ as expected.
So ‘androidExec(success, …)’ is never executed. success is the callback for executeScript.

var msgs = nativeApiProvider.get().exec(bridgeSecret, service, action, callbackId, argsJson);
if (jsToNativeBridgeMode == jsToNativeModes.JS_OBJECT && msgs === "@Null arguments.") {
        androidExec(success, fail, service, action, args);

Any Idea? Thank you in advance.

1 Like

I’m in the same problem…
I’ve been searching but nothing to fix this yet…


I found this, hope helps you! :grin:
The problem is that executeScript is a promise itself, so to make your code working you must write something like this:

$rootScope.$on(’$cordovaInAppBrowser:loadstop’, function (e, event) {
code: “alert(1+1);”
function (values) {
alert(‘add completed’);


Thanks man,
you saved my life :smiley:
Works like a charm. This should be added to ngCordova documentation.

Hi! Great idea, having some similar problems with cordova saying ‘callback is not a function’. Where did you place that code? app.js or in with the service you are using?


On my case:

checkInAppBrowserObject.executeScript({code: 'document.getElementsByClassName("fr66n")[0].innerHTML'})

If the element fr66n is not present in the HTML the callback is not fired (then, catch)

Some idea?