contently/xdomain-cookies

location.hash var error

mpbunch opened this issue · 0 comments

JSON.parse needs a value otherwise it dies and kills the script.

Uncaught SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at xdomain_cookie.html:8

Simple solution:

var _hash_data = '';
if(window.location.hash.substr(1)){
  _hash_data = JSON.parse(decodeURIComponent(window.location.hash.substr(1)));
}