title: JavaScript Session storage variable on another page
body: <p>So I'm rather new to JavaScript and I would love some help getting this code to work. I've looked at multiple other posts talking about session storage as well as if/else statements and still can't seem to figure it out.</p>
  
  <p>I have a page, lets call it page 1 and it has 3 links, "red" "green" and "blue". </p>
  
  <p>When you click on any of these links its function sets a session storage variable 'colorVar' to the color chosen and then redirects to a page called page 2.</p>
  
  <p>As page 2 loads, the window.onload action is used to start a function according to the variable set on page 1. In this case the function that starts on page 2 simply displays "Your color is ____!".</p>
  
  <p>Heres the code:</p>
  
  <pre><code>&lt;!-- [This is Page 1] --&gt;
  
  &lt;a href="Page2.html" onclick="colorRed()"&gt;Set color to red&lt;/a&gt;
  &lt;a href="Page2.html" onclick="colorBlue()"&gt;Set color to blue&lt;/a&gt;
  &lt;a href="Page2.html" onclick="colorGreen()"&gt;Set color to green&lt;/a&gt;
  
  &lt;script&gt;
  
  function colorRed() {
        sessionStorage.setItem("colorVar", "red"); 
  }
  function colorBlue() {
       sessionStorage.setItem("colorVar", "blue");
  }
  function colorGreen() {
       sessionStorage.setItem("colorVar", "green"); 
  }
  &lt;/script&gt;
  
  &lt;!-- [This is Page 2] --&gt;
  
  &lt;script&gt;
  window.onload = sessionStorage.colorVar + 'Write()';
  
  function redWrite() {
      document.write("Your color is red!")
  }
  
  function blueWrite() {
      document.write("Your color is blue!")
  }
  
  function greenWrite() {
     document.write("Your color is green!")
  }
  &lt;/script&gt;
  </code></pre>