addEventListener('exit') to inappbrowser in PhoneGap
addEventListener('exit') to inappbrowser in PhoneGap
当inappbrowser关闭时,我试图退出我的应用程序。我试图这样做通过添加一个事件监听器到浏览器,然后从那里…比如exit(0)之类的。但是它不工作,警报从未到达。
有人知道为什么吗?此外,如果你有一个更好的主意如何退出应用程序时,inappbrowser关闭,请分享。
我正在使用phonegap。
var ref = null;
ref = window.open('http://google.com', '_self', 'location=no');
ref.addEventListener('exit', function(event) { alert("hello");});
只使用"平等"的"_self"。如果在现有视图中打开外部源,'exit'事件不会触发。
退出应用程序使用
navigator.app.exitApp();
完整代码:
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'
);
}
似乎inappbrowser的loadstop事件在_self加载的inappbrowser中也不会被触发。
相关文章:
- Node.js's Buffer.writeFloatBE in Javascript
- Setting default onclick behavior for <img> tag in gene
- Lucene Search in Alfresco
- grep in JQuery to C#
- write HTML in JavaScript
- jQuery setTimeOut: in for-loop
- SetTimeout and clearTimeout in Javascript
- lightbox in html 5 and javascript
- HTMLInputElement in IE7
- Mongodb$in以与数组中相同的顺序获取结果
- element.dataset in Internet Explorer
- jQuery parent() in table
- Instagram oauth flow in angularjs
- In循环的In运算符前后
- 如何使用for in循环在javascript中显示对象中的对象
- Jquery change onchange in onload
- 重构 jQuery in JS 问题
- strongloop script.js run find in before delete方法:如何同步运行异步方法
- TicTacToe minimax AI in Javascript
- addEventListener('exit') to inappbrowser in PhoneGap