jQuery Mobile multi-page application. How to check if history.back() is possible without leaving the application? -


In my jQuery mobile multi-page application, is it possible to check that there will be a page in history.back () application?

I have a link on a sub-page, which I want to execute history.back () if it refers to any subpopulation in the application or just explicitly linking the application from the main page otherwise

I want to do something like this

if (canbaback) {$ .mobile.back ();} and {$ .mobile.changePage ('# main '};}

On the initial load of the app, a flag is stored in the history state Objects on the document Kat Current:

  $ (function () {history.replaceState ($. Extension (history.state, {root: true}));};  

Since then, whenever we want to check that we can go back, just see that the flag that we set is in the current history state object. If so, we are on the starting page and can not go back:

  function canGoback () {Return! (History.state & amp; history.state.root); }  

HTML:

  & lt; A href = "javascript: if (canGoback) {$ .mobile.back ();} and $ .mobile .changePage ('#home');}" & gt; Back & lt; / A & gt;  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -