title: Show a div only once per time the user is on the site
body: <p>I'm trying to show a div element only once per time that the user is on the site. I've seen multiple answers to similar questions already, but none of them seem to work... I have a code written out, but it doesn't work... I got a part of the code from somewhere else (I can't remember) so is that why it doesn't work?</p>
  
  <p>Here's the code</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  //&lt;![CDATA[
  
  var once_per_session=1
  
  
  function get_cookie(Name) {
    var search = Name + "="
    var returnvalue = "";
    if (document.cookie.length &gt; 0) {
      offset = document.cookie.indexOf(search)
      if (offset != -1) { // if cookie exists
        offset += search.length
        // set index of beginning of value
        end = document.cookie.indexOf(";", offset);
        // set index of end of cookie value
        if (end == -1)
           end = document.cookie.length;
        returnvalue=unescape(document.cookie.substring(offset, end))
        }
     }
    return returnvalue;
  }
  
  function alertornot(){
  if (get_cookie('alerted')==''){
  loadalert()
  document.cookie="alerted=yes"
  }
  }
  
  function loadalert(){
  document.getElementById("popupp").style.visibility = visible;
  
  if (once_per_session==0)
  loadalert()
  else
  alertornot()
  
  //]]&gt;
  &lt;/script&gt;
  
  &lt;div class="popupp" style="visibility:hidden;"&gt;hi&lt;/div&gt;
  </code></pre>
  
  <p>Do you think you could help me figure out what's wrong with it?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I've got it! Here it is: </p>
  
  <pre><code>&lt;script type='text/javascript'&gt;//&lt;![CDATA[ 
  window.onload=function(){
  (function() {
      var visited = localStorage.getItem('visited');
      if (!visited) {
          document.getElementById("popupp").style.visibility = "visible";
          localStorage.setItem('visited', true);
      }
  })();
  }//]]&gt;  
  
  &lt;/script&gt;
  
  
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id="popupp" style="visibility:hidden;"&gt;hi&lt;/div&gt;
  
  &lt;/body&gt;
  </code></pre>