title: Javascript: Retain class if page refresh after scrolling
body: <p>I'm using the following javascript to add a class to a top menu after the page has been scrolled 170px.  This works great.  </p>
  
  <pre><code>$(document).ready(function($) {
      $(window).scroll(function () {
          if ($(window).scrollTop() &gt; 170) {
              $('header').addClass('shrink');
          }
          else{
              $('header').removeClass('shrink');
          }
      });
  });
  </code></pre>
  
  <p>The problem happens on reloading the page past the 170px point, the menu gets the default class until the page is scrolled.  This site has the same problem: <a href="http://metropolisspasalon.com/" rel="nofollow">http://metropolisspasalon.com/</a> The menu is black by default then turns white after scrolling.  When the menu is white and you reload the page, it turns black again.</p>