user888734
user888734

Reputation: 3897

History API in Safari - pushState / replaceState - state undefined

The following works in Chrome and Firefox, but not in Safari (6.0.2):

var data = [];
data.Message = "hi!"
history.pushState({Data:data}, '', document.location.href);
console.log(history);
alert(history.state.Data.Message);

In Safari, the console log for the history state is undefined, as is the message. The same is true for replaceState.

Fiddle here: http://jsfiddle.net/wYV9d/3/

Upvotes: 0

Views: 2458

Answers (1)

user888734
user888734

Reputation: 3897

It's because I created Data as an array instead of an Object.

var data = {};

works just fine.

Upvotes: 2

Related Questions