I'm trying to implement AddeventListener to listen 'Exit' and 'LoadStart' for InAppBrowser in IONIC2
我正在尝试实现AddeventListener来监听IONIC2中InAppBrowser的'Exit'和'LoadStart'
my html
<button (click)="browsersystem('https://www.google.com')" > URL</button>
mt.TS file
browsersystem(url:string)
{
this.platform.ready().then(() => {
let browser=open(url, "_system", "location=true");
browser.addEventListener('exit',()=>
{
console.log('Browser Closed');
alert('Browser Closed');
})
browser.addEventListener('loadstart',()=>
{
console.log('Browser STARTED');
})
});
}
No errors on console.
控制台没有错误。
Is there something am i missing ??
我错过了什么?
2 个解决方案
#1
1
import {InAppBrowser} from 'ionic-native';
...
let browser=InAppBrowser.open(url, "_system", "location=true");
browser.addEventListener('exit',()=>
{
console.log('Browser Closed');
alert('Browser Closed');
});
This is not at all how it's documented / how it should work, but as the code currently stands, this is what works for me.
这根本不是它如何记录/它应该如何工作,但正如代码目前所说,这对我有用。
#2
1
This should do the trick, see below :
这应该可以解决问题,见下文:
this.platform.ready().then(success => {
let browser = new InAppBrowser(url, '_system');
browser.on('exit').subscribe(
() => {
console.log('done');
},
err => console.error(err));
});
#1
1
import {InAppBrowser} from 'ionic-native';
...
let browser=InAppBrowser.open(url, "_system", "location=true");
browser.addEventListener('exit',()=>
{
console.log('Browser Closed');
alert('Browser Closed');
});
This is not at all how it's documented / how it should work, but as the code currently stands, this is what works for me.
这根本不是它如何记录/它应该如何工作,但正如代码目前所说,这对我有用。
#2
1
This should do the trick, see below :
这应该可以解决问题,见下文:
this.platform.ready().then(success => {
let browser = new InAppBrowser(url, '_system');
browser.on('exit').subscribe(
() => {
console.log('done');
},
err => console.error(err));
});