title: How to set window.open tab in local storage in javascript
body: <p>I am using</p>
  
  <pre><code>window.open(newTabUrl, "toolbar=yes,scrollbars=yes,resizable=yes", "width=500,height=500");
  </code></pre>
  
  <p>which is working fine if I did not refresh page.</p>
  
  <p>But I want to maintain this value in one variable and set in the local storage. When I go to another page, if new window is opened I want to refresh that new window when I open new document. This is working if I am in the same page.</p>
  
  <p>I am using this code to set value in the local storage:-</p>
  
  <pre><code>myWindow = window.open(newTabUrl, "toolbar=yes,scrollbars=yes,resizable=yes", "width=500,height=500");
  
  newDocumentWindow = true;
  localStorage.setItem("newDocumentWindow", newDocumentWindow);
  localStorage.setItem("myWindow", myWindow);
  </code></pre>
  
  <p>When page is refreshing I am using</p>
  
  <pre><code>var myWindow = localStorage.getItem("myWindow");
  </code></pre>
  
  <p>It gives me <code>["object window"]</code></p>
  
  <p>When I am assigning this code to refresh page like this:</p>
  
  <pre><code>myWindow.location.href = newTabUrl;
  myWindow.focus();
  </code></pre>
  
  <p>It is not working. Please help me how to store window.open value in local storage and get value from local-storage during page refresh.</p>