window.history.pushState

1

I'm using the pushState function to populate history , so alright, but it's time to use windows.history.back() only to go back once. The function you add is as follows:

function activate_page(sel, have_state)
{
    var $dn = $(sel);
    var is_vis = $dn.is(":visible");
    if(!is_vis)
    {
        $dn.parents("body").find(".upage").addClass("hidden");
        $dn.removeClass("hidden");
        window.history.pushState({upage:sel}, sel, document.location.origin + document.location.pathname +sel);
        $(document).trigger("pagechange");
    }

}

And to go back I use:

angular.module('ionic')
  .run(function($ionicPlatform,$ionicPopup, $state,$ionicHistory){
    $ionicPlatform.registerBackButtonAction(function (event) {
      //console.log(window.history);
      if($state.current.name=="app.listar_CELULAS"){
        alert("entro aqui");
        navigator.app.exitApp();
      }
      else {
        window.history.back();
      }
    }, 100);
});

I need it to come back all the way to the beginning of the stack, the way it is doing it, it only returns one page.

Thank you in advance.

    
asked by anonymous 07.01.2016 / 19:41

1 answer

1

The function of window.history.back () is to just go back 1 page, to go back more you should use the window.history.go (- > number of pages returned ")

Take a look at this response, the situation is similar to your " window.history.back returning only one page "

    
03.07.2018 / 20:42