1

I'm using History.js and all is working fine.

Except for when there is a quote in the URL.

Then instead of working properly, the page loads and suddenly the statechange event is fired and my binded function is called.

This happens when users hit my site after it was liked on Facebook and they clicked on the link, Facebook adds a bunch of parameters to the URL, for example: &action_type_map={"183745848938475":"og.likes"}

Once a user arrives to my site with a " in the url the statechange is invoked (after the page loads) and the page thinks the user is trying to navigate somewhere.

Any ideas why the event is fired and what I can do to stop this behavior?

Guy
  • 317
  • 3
  • 16

1 Answers1

0

Catch the statechange event, do some sanitize stuff or prevent it from executing normally by returning false.

return false;

See this SO question:

Statechange is firing whenever i do a push-state

Community
  • 1
  • 1
roland
  • 7,695
  • 6
  • 46
  • 61
  • The problem I am having is the statechange event is fired when there is a quote in the url. The link is external (Facebook creates it in this case) so I can't control it. – Guy Jan 23 '14 at 20:24
  • Statechange is supposed to fire when pushing state, that is not the problem. The problem is that it's fired for some reason based on the url even though it isn't supposed to. I can handle the specific case in my handler but I don't want the event to fire. – Guy Jan 23 '14 at 21:52