Control the actions of the Android back button with Javascript

0

Good afternoon guys.

I'm working with a hybrid app using Phonegap.

I created the structure in single html and the navigation is through 3 divs that by javascript, I hide / display.

I got a function where I control the action of the back button of the android to always open the div that would be the initial screen when clicked:

function Voltarhome() {
    document.addEventListener("deviceready", onDeviceReady, false);
}

// device APIs are available
//
function onDeviceReady() {
    // Register the event listener
    document.addEventListener("backbutton", onBackKeyDown, false);
}

// Handle the back button
//
function onBackKeyDown() {        
    abreHome();
}

Now I need to change the back button action whenever I'm in the initial div. I already have the function to close the App, I just need to know how to change the action of the back button being that when loading the application it already has the function to open the initial div.

Thank you

    
asked by anonymous 17.12.2018 / 19:54

0 answers