nablex
nablex

Reputation: 4757

HTML5 history pushState is not working

Not sure what I'm doing wrong, but this small bit of code does not work:

window.history.pushState("foo", "foo", "foo");

It will generate the following error in firefox 29:

TypeError: window.history.pushState is not a function

Upvotes: 3

Views: 5830

Answers (2)

Janty
Janty

Reputation: 1714

Please try as

Suppose http://mozilla.org/foo.html executes the following JavaScript:

var stateObj = { foo: "bar" };
history.pushState(stateObj, "page 2", "bar.html");

It should work as per Mozzila.

Please find more On Mozilla Link

Upvotes: 0

nablex
nablex

Reputation: 4757

Apparently one of the scripts I included had a declaration:

var history = ...;

Unbeknownst to me, all vars on the root actually live in the window scope so the custom history var actually overwrote the original window.history.

Upvotes: 2

Related Questions