0

I have developed an application in phoneGap Android.
In my App back button is not working properly.

I used this code to navigate the form:

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();
    }    
}

its working is as following:

for example i have three page a.html, b.html, c.html
I'm navigating from a.html to b.html to c.html

issues

when i click back button, it navigate from c.html to b.html,
again the process is repeat, it wont go to a.html.

Ronak Mehta
  • 5,971
  • 5
  • 42
  • 69
JavaH
  • 427
  • 2
  • 11
  • 29

2 Answers2

0

By your explanation i come to a conclusion that,When you are navigating form C.html to B.html,Now Back screen(histroy(-1)) for C.html is B.html and this will repeat continuously.My point is make B.html as previous screen and A.html as Previous of previous screen.

subbu
  • 146
  • 2
  • 8
0

If html you simply want to have "regular" back behaviour, remove all your code. If you are loading separate .html files the default history stack will kick in and properly load between pages.

fil maj
  • 2,260
  • 16
  • 16