Skip to content

beforeload event throws "Method 'loadAfterBeforeload:' not defined in Plugin 'InAppBrowser'" when callback is called #349

@guycalledseven

Description

@guycalledseven

I am very interested in PR #276 (beforeload event) by @wvengen , but in current master it does not work anymore. PR did not work for me completely after it was merged but did not throw errors (after closing IAB it would cause major issues). But at some point it started reporting errors.

I pinpointed commit which broke functionality (at least for me on IOS) - c41f5b5

After this commit this is the error which shows when callback is called from inside the listener.

ERROR: Method 'loadAfterBeforeload:' not defined in Plugin 'InAppBrowser'
2018-11-20 15:12:48.310426+0100 IZZI[2373:503538] FAILED pluginJSON = ["INVALID","InAppBrowser","loadAfterBeforeload",["https:\/\/www.example.com\/"]]

example usage:

declare var window:any;
...
const app = window.cordova.InAppBrowser.open(url, "_blank", 'beforeload=yes');
app.addEventListener('beforeload', this.beforeloadCallback);
...
private beforeloadCallback(params, callback) {
	callback(params.url);
}

My params var contains: {"type":"beforeload","url":"https://www.example.com/"}
My callback var contains:

function (strUrl) {
strUrl = urlutil.makeAbsolute(strUrl);
exec(null, null, 'InAppBrowser', 'loadAfterBeforeload', [strUrl]);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions