调用默认的PhoneGap后退按钮处理 [英] Calling Default Phonegap Back Button Handler
问题描述
我有一个PhoneGap的应用程序,需要我捕捉后退按钮。这工作顺顺当当,但是当我在主屏幕和返回按钮是pssed我想打电话给原来的事件处理程序,让应用程序关闭或做任何顺其自然的平台,这样的preSS $ P $。我知道我可以告诉应用程序退出却明白,这是不好的形式对iPhone应用程序。
无论我怎么努力(我已经尝试了许多的东西),我不能得到原始的处理程序火灾。任何建议?
在我的code我有我的后退按钮事件处理中switch语句根据需要的效果,用来指导应用:
开关blahBlah
{
情况下,这个:
做这个() ;
打破;
案件的主要:
//我该怎么办这里是很乖的所有平台???
打破;
默认:
doFoo();
}
只要您登陆主屏幕上,并删除您的自定义事件处理程序检测。
document.removeEventListener(后退按钮,函数(){},FALSE);
和添加事件侦听器上的其他页面(或部分)。
document.addEventListener(后退按钮,OverrideBackButton,假);
希望有所帮助。
I have a phonegap app that requires I capture the back button. This works swimmingly but when I am at the main screen and the back button is pressed I want to call the original event handler and let the app close or do whatever comes naturally to the platform with such a press. I know I can tell the app to quit but understand this is bad form for iPhone apps.
No matter what I try (and I have tried many things) I cannot get the original handler to fire. Any advice?
In my code I have a switch statement inside my backbutton event handler that directs the app as needed to the effect of:
switch blahBlah
{
case 'this' :
doThis() ;
break;
case 'main' :
// What do I do here that is well behaved for all platforms???
break;
default:
doFoo() ;
}
Detect whenever you land on the main screen and remove your custom event handler.
document.removeEventListener( "backbutton", function(){}, false );
and add the event listener on the other pages (or sections).
document.addEventListener( "backbutton", OverrideBackButton, false );
Hope that helps.
这篇关于调用默认的PhoneGap后退按钮处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!