window.history.pushState

Asked

Viewed 279 times

1

I’m using the function pushState to populate the history, until then all right, but he at the time to use the windows.history.back() can only return once. The function you add is the following:

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 return 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 him to go all the way back to the top of the pile, the way he’s doing he only comes back one page.

Thank you from now on.

  • Here is a similar question with an answer: http://answall.com/questions/105371/window-history-back-voltando-apenas-umap%C3%A1gina

1 answer

1

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.