i make an application on phonegap. I need to get content html from inappbrowser when i click Close button at toolbar but it isnot working. this is my code:
var handleClose = function() {
// get content html from here
}
ref.addEventListener('exit', handleClose);
Can someone help me?
To help anyone in future, I've just stumbled across this same question and found a solution.
var inAppRef = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
inAppRef.addEventListener('loadstop', function() {
inAppRef.executeScript({
code: "document.getElementsByTagName('html')[0].innerHTML"
}, function(html) {
alert(html);
});
});
Remember you need to reference and include the InAppBrowser through phonegap / cordova.
To build upon the answer from Ralphonzo, for the current version of in-app-browser (v3.0.0) and ionic (v4.6.0) and cordova (v7.1.0) with Angular (v7.2.8), this works for me:
ngOnInit() {
this.browser = this.iab.create(domain + sso_url, '_blank', {});
this.browser.on('loadstart').subscribe((event: InAppBrowserEvent) => {
this.browser.executeScript({code: 'document.getElementsByTagName("html")[0].innerHTML'}).then( html => { console.log(html) });
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With