Android 后退按钮工作不正常?
我已经在phoneGap Android中开发了一个应用程序。Android 后退按钮工作不正常?,android,button,cordova,back,Android,Button,Cordova,Back,我已经在phoneGap Android中开发了一个应用程序。在我的应用程序中,后退按钮不能正常工作 我使用以下代码浏览表单: document.addEventListener("backbutton", handleBackButton, true); function handleBackButton() { if (typeof(navigator) != 'undefined' && typeof(navigator.app) != 'undefined' &
在我的应用程序中,后退按钮不能正常工作 我使用以下代码浏览表单:
document.addEventListener("backbutton", handleBackButton, true);
function handleBackButton()
{
if (typeof(navigator) != 'undefined' && typeof(navigator.app) != 'undefined' && typeof(navigator.app.backHistory) == 'function')
{
history.go(-1);
navigator.app.backHistory();
}
else
{
history.go(-1);
//navigator.app.backHistory();
}
}
其工作如下:
例如,我有三页a.html
,b.html
,c.html
我正在从
a.html
导航到b.html
导航到c.html
问题
当我点击后退按钮时,它从
c.html
导航到b.html
,这个过程再次重复,它不会转到
a.html
,根据您的解释,我得出结论,当您从c.html导航到b.html时,现在返回屏幕(历史(-1))因为C.html是B.html,这将不断重复。我的观点是将B.html作为上一屏幕,将A.html作为上一屏幕的上一屏幕 如果您只是想有“常规”的返回行为,请删除所有代码。如果加载单独的.html文件,默认历史堆栈将启动并在页面之间正确加载。您使用的是任何ui框架,如JqueryMobile