[英]addEventListener('exit') to inappbrowser in PhoneGap
I'm trying to exit out of my application when the inappbrowser closes. 当inappbrowser关闭时,我正试图退出我的应用程序。 I'm trying to do so by adding a eventlistener to the browser, and then from there.. maybe like exit(0) or something.
我试图通过向浏览器添加一个eventlistener,然后从那里...也许像exit(0)或其他东西。 But it's not working, the alert is never reached.
但它不起作用,从未达到警报。
Does somebody know why? 有人知道为什么吗? Also if you have a better idea on how to exit the app when the inappbrowser closes, please share.
此外,如果您在关闭inappbrowser时如何更好地了解如何退出应用,请分享。
I'm using phonegap. 我正在使用phonegap。
var ref = null;
ref = window.open('http://google.com', '_self', 'location=no');
ref.addEventListener('exit', function(event) { alert("hello");});
Just use "_blank" instead of "_self" . 只需使用“_blank”而不是“_self” 。 The 'exit' event wont fire if external source opened in the existing view.
如果在现有视图中打开外部源,则“exit”事件将不会触发。
To exit the app use 退出应用程序使用
navigator.app.exitApp();
Complete code: 完整代码:
var ref = window.open('http://google.com', '_blank', 'location=no');
ref.addEventListener('exit', function(event){ Exit(); });
function Exit(){
navigator.notification.confirm(
'Do you want to exit app?',
function(i){
if(i==2)
{
navigator.app.exitApp(); //This will Close the App
}
},
'App Name',
'Cancel,Exit'
);
}
Hope this will help you. 希望这会帮助你。
似乎inappbrowser的loadstop事件也不会在_self加载的inappbrowser中被触发。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.