Note that there are some explanatory texts on larger screens.

plurals
  1. POHistory.js and refresh
    text
    copied!<p>I'm building a article listing and when a visitor click on a article my site loads in the full article with help of ajax and make a pushState with the article url to example article.php?id=55 so when a visitor refresh or visit the url they will land on the "article item" page instead of the list page.</p> <p>But now to my problem when a visitor refresh my page when the url have been changed he land on the "article item" page as i wont but if he wants go back to my article listing by pressing the back button nothing happens, and i have no good idea to solve this problem.</p> <p>I know that popState gets triggered when someone click on back button so i can always set a regexp there and redirect the user but it does not feel correct. </p> <p>Have someone here played around with history.js or native history (html5)? I appreciate all the help, just shoot!</p> <p>Example: </p> <pre><code>$(".list-item a").click(function(e){ e.preventDefault(); History.pushState(null, $(this).text(), $(this).attr('href')); div = this; }); </code></pre> <p>Live example. Githubs trees <a href="https://github.com/blog/760-the-tree-slider" rel="nofollow">https://github.com/blog/760-the-tree-slider</a>.</p> <p>EDIT: Have tested alot of shit now but dont get it to work. One solution is to use History.replaceState(null, null, location.href); location.reload();</p> <p>Inside my "item.php" but this code should just get trigged when i press back button. But when i lissen on popstate it's get triggered on init.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload