Friday, January 26, 2018

Share data between html pages

  1. Pop out a window using a hashtag and appends the data that needs to be shared
    • var childNoteWindow = window.open(URL + "popout.html#" + JSON.stringify(params), target, windowoption);
  2. The pop out window retrieves the data
    • var paramString =window.location.hash.substr(1);
  3. The pop out window clears the hashtag detail from the URL. Added bonus: this does not cause page refresh.
    • history.pushState("", document.title, window.location.pathname + window.location.search);
Only available with HTML5.

No comments: