Software Archive
Read-only legacy content
17061 Discussions

the question about backbutton event

Wang_Y_2
Beginner
414 Views

i register the backbutton listener in index page ,it works when i press the back button.but in the second level page,there is no response

 

for example:

index.js:

document.addEventListener("deviceready", onDeviceReady, false);


    // Cordova is loaded and it is now safe to call Cordova methods
    //
 function onDeviceReady() {
        //alert(999);
        // Register the event listener
        document.addEventListener("backbutton", onBackKeyDown, false);
    }

index.html:

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script src="js/index.js"></script>

 

0 Kudos
3 Replies
Dale_S_Intel
Employee
414 Views

Are you testing this in the Emulator, or with App Preview or Debug?

Dale

 

0 Kudos
Dale_S_Intel
Employee
414 Views

I'm seeing the same issue.  It looks like it's not working in Cordova 5.1.1 but is working in 4.1.2.  If it works for you to change Cordova versions I would recommend that until there is a fix.  To do that go to your projects page, expand "Build settings" then look for "Cordova CLI Version".  Click on that circle just to the right of the version number and you should see a drop-down menu with two choices, just switch that to 4.1.2 and see if that works for you.  Note, if you're using some third party plugins you may need to make sure they're the appropriate version to work with that Cordova version, as a lot changed between 4 and 5.

Meanwhile I'll do what I can to try to get a fix for Cordova 5.  I'll update here when I have more info.

 

Dale

 

0 Kudos
Wang_Y_2
Beginner
414 Views

I testing this with android phone

0 Kudos
Reply