5

I am building a Cordova 3 app. I'm loading a url to my appview and on certain cases i'm opening a fullscreen view on top of the appview. In these cases I would like the back button to only remove my top view, and not perform the built in "goBack" method. I didn't manage to override the back click behaviour in inner pages. I noticed I'm getting to my "onBackPressed" listener function only when I click "back" from my initial URL page, inner pages seem to disable the "back" event propagation and always perform browser back navigation.

I found this post: Override Android Backbutton behavior only works on the first page with PhoneGap but it seemed only relevant to older cordova versions.

Any help would be appreciated.

Thanks!

Community
  • 1
  • 1
micmic
  • 53
  • 4

1 Answers1

0

This is the same problem i faced, I simply fix this by adding the following code in my each HTML page

<head>
<script type="text/javascript">
    function onLoad()
    {
        document.addEventListener("deviceready",onDeviceReady,false);
    }
    function onDeviceReady()
    {
        document.addEventListener("backbutton",noth,false);
    }
    function noth()
    {
        //code for what happends if back button is pressed
    }
</script>
</head>
<body onload="onLoad()">
</body>


Using this code i created a phonegap app it shows a confirm message like 'exit app ?' if you pressed back button in main html file while in other cases it shows previous html page
For reference: Phonegap - navigator.app.backHistory() not working on HTML back button

Community
  • 1
  • 1
salih kallai
  • 879
  • 2
  • 13
  • 34