Questions tagged [html5-history]

The HTML5 History API allows programmatic manipulation of the browser's history through JavaScript, providing a method of managing the user's history stack when creating web applications.

The HTML5 History API allows programmatic manipulation of the browser's history through JavaScript, allowing interaction with the browser's history as though it is the user.

Useful documentation:

585 questions
18
votes
0 answers

Need to click twice to go back in history (using pushState)

I've got a page with some select-fields. Once the user changes the value of a select-field, a new history-object is created using the values of all select-fields as a state object: $(".chosen-select-field").chosen().change(function() { …
Hedge
  • 13,498
  • 35
  • 122
  • 223
15
votes
3 answers

Title of history.pushState is unsupported, what's a good alternative?

The second parameter of History.pushState and History.replaceState can be used to set the "title" of the history entry. This means that when the user clicks through page 1 to page 8, this is what he should see in his history bar: And it is working…
Pacerier
  • 76,400
  • 86
  • 326
  • 602
15
votes
1 answer

Differentiate between back button pressed and forward button pressed with History API

I'm using the history API to push a new URL to the web page without reloading it. I have multiple buttons that all have different functionality. My script now works almost without problems. When I press the button something happens, and when I go…
Musterknabe
  • 4,781
  • 9
  • 52
  • 101
15
votes
2 answers

history pushState and scroll position

I am trying to retrieve the scroll position when a user navigates back in the browser history using HTML5 popstate handler. Here is what I have: $(document).ready(function () { $(window).on('popstate', PopStateHandler); …
George Filippakos
  • 14,863
  • 12
  • 75
  • 86
14
votes
1 answer

How to configure Nginx with React Router HistoryLocation?

I'm currently using Nginx as a reverse proxy and to serve my static assets. I was using React Router's HashLocation setting since it was the default and it allowed me to refresh on a route with no problems and no need for any additional…
Jimmy Gong
  • 1,485
  • 3
  • 16
  • 28
14
votes
1 answer

Is there a callback for History.pushstate?

My Google-fu pulls up nothing. When you do this: var stateObj = { state: "some state" }; history.pushState(stateObj, "page 2", "other.htm"); Is there an associated window callback? I know that there's this: window.onpopstate = function()…
thekevinscott
  • 4,661
  • 8
  • 38
  • 54
13
votes
1 answer

Restoring content when clicking back button with History.js

I've implemented History.js on a local test application. Everything seems to work, however if I press the back button in the browser, the previous content does not get restored. Do I actually have to load the content manually again (i.e. make…
user990827
  • 513
  • 5
  • 10
12
votes
1 answer

replaceState(): a history state with url ... cannot be created in a document with origin

I have window.history.replaceState(null, null, 'about'); in main.js which are located in required/javascripts on my server. Then on the about page (located in / (root) on my server), I have a link that uses window.history.replaceState(null, null,…
Airikr
  • 5,214
  • 12
  • 50
  • 100
12
votes
3 answers

HTML5 History API: JSON displayed when going "back" to another page, and then "forward" again

I have a page where there are several search / filter button which, when clicked, refresh the contents of a list below through AJAX. In the process, I'm modifying history (through pushstate) so that the new filtered page is bookmarkable, and so the…
Daniel Magliola
  • 27,613
  • 56
  • 154
  • 235
11
votes
3 answers

Is History API consistent across modern browsers?

History API is now supported in every popular browser. It seems there's no need for hash fallbacks, _escaped_fragment_ tricks or other workarounds anymore. Cool libraries from 2013 like History.js seem useless now. But there are some things where…
11
votes
2 answers

For AngularJS web app: webpages don't remember their last scroll positions when navigating back to them with the back button. Why? How to fix?

When navigating around the developer's guide for AngularJS, I noticed that I do not go back to my last scroll position when navigating back to a page using the back button. Instead, I go right back to the top. Since the developer's guide is built…
ememem
  • 928
  • 1
  • 10
  • 22
10
votes
2 answers

Removing current page from browser history

I'm building a text editor in my website, the workflow is as follows. In /list, the user picks an entry they want to edit from a list which takes them to /edit/[article_id]. The user does their work, and then clicks submit. The server processes the…
starleaf1
  • 1,997
  • 1
  • 29
  • 55
10
votes
5 answers

Should I use an iframe rather than ajax?

We're building a Drupal site with an audio player which should keep playing while you browse the page (something like soundcloud). Currently we're loading clicked 's sites with AJAX and inject the HTML into the page and use history.js to…
Alex
  • 9,339
  • 2
  • 28
  • 46
10
votes
3 answers

Ember.js restore scroll on history, reset scroll on link

Daniel F Pupius described the problem as: Lots of sites get this wrong and it’s really annoying. When the user navigates using the browser’s forward or back button the scroll position should be the same as it was last time they were on the page.…
Bouke
  • 10,025
  • 6
  • 49
  • 88
10
votes
1 answer

Why is event.state on window.onpopstate empty when pushing with same location.href (or empty)

When pushing to history and setting data without changing URL: window.history.pushState({ stateName: "myStateName", randomData: window.Math.random() }, "myStateName", location.href); .... and then listen to the pop event and trigger it by…
PerMafrost
  • 499
  • 3
  • 17
1
2
3
38 39