Phonegap - navigator.app.backHistory() not working on HTML back button

前端 未结 4 1606
灰色年华
灰色年华 2020-11-29 06:27

In my app i am using phonegap 2.6.For back button, I am using the following function

document.addEventListener(\"backbutton\", onBackKeyDown, false);

functi         


        
4条回答
  •  旧时难觅i
    2020-11-29 06:29

    I have tried 3 separate things when I faced the same situation:

    • window.history.back()

    • navigator.app.backHistory();

    • History.go(-1);

    Individually, none of these solve the problem. I put all 3 things together and much to my surprise it worked. I really don't know what is behind it.

    Then I decreased to two functions and removed:

    • window.history.back()

    Now I am using this function and it is working fine.

    //Works Fine
    function onBackKeyDown() {
        history.go(-1);
        navigator.app.backHistory();
    }
    

提交回复
热议问题