Domanda

I have some back/next buttons set up for a phonegap app built in angular.js.

I'm using partials in angular for the pages and using window.history as some simple back/next buttons. All is working good but I'd like to add some visual feedback as to when the back and next functionality becomes available.

Is there a way to check if the history.forward is available? the next page wont be known, so I dont think looking through the pages in the history is a viable solution to this, it shouldnt kneed to know what page its on or what pages the app contains, something like (sudo)

if(window.history.forward()){
  // show buttons as available
}else{
  // show buttons as not available
}

Sadly history only returns undefined, but is there any other way?

Any suggestions would be great

thanks

È stato utile?

Soluzione

history doesn't allow this, still you can get history.length to check if there is history at all (if not - just disable both buttons).

Or you can "dirtyhack" it by wrapping the whole site or app with 100% width|height borderless iframe on your "index" page and log this iframe's hisory "manually" from the top window (not advised at all; will work for the same domain only; will not work with "X-Frame-Options:DENY" on your server).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top