title: jquery scroll to named anchor when navigating from other page
body: <p>I have a submenu that is expanded on all pages of my site. The submenu contains links to named-anchors within one page which the parent menu item links to. I am using jquery scrollTO and localScroll successfully to animate scrolling within the page with the named-anchors but if I navigate to a named-anchor from a different page within the site it does not retain the animated scroll or specified offset from the top. Is there a way to do this?</p>
  
  <p>I greatly appreciate any feedback!!
  Cecilia</p>
  
  <p>Below is an example of the html I’m working with. I have a fixed menu on the left side and a fixed header. Right now this animates when you click on the anchor links in the submenu and stops with the active named anchor 150px from the top of the window so that it does not disappear underneath the fixed header. </p>
  
  <p>If possible, I'd like to have the window scroll to the named-anchor when navigating from one of the other pages but most importantly I have to retain the offset 150px from the top. Right now it stops 0px from the top and disappears underneath the header when clicking on an anchor link from another page. </p>
  
  <pre><code>&lt;head&gt;
  &lt;script type="text/javascript" src="js/jquery-1.4.2.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="js/jquery.scrollTo-min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="js/jquery.localscroll-min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" &gt; 
  $.localScroll({offset:-150});
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;div id="page"&gt;
      &lt;div id="header-bg"&gt;&lt;!-- fixed header --&gt;
      &lt;div id="header"&gt;
      &lt;div id="logo"&gt;&lt;a href="/" title="Home" rel="home"&gt;&lt;img src="logo.jpg" alt="Home" id="logo-image" /&gt;&lt;/a&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;/div&gt; 
  &lt;div id="main"&gt;
  
  &lt;div id="sidebar-left"&gt;&lt;!-- fixed menu --&gt;
  &lt;ul class="menu"&gt;
  &lt;li class="expanded"&gt;&lt;a href="/page1" title="Page 1" class="active"&gt;Page 1&lt;/a&gt;&lt;!-- parent --&gt;
          &lt;ul class="menu"&gt;&lt;!-- sub-menu linking to named anchors --&gt;
          &lt;li&gt;&lt;a href="/page1#anchor1"&gt;Anchor-link 1&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="/page1#anchor2"&gt;Anchor-link 2&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="/page1#anchor3"&gt;Anchor-link 3&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="/page1#anchor4"&gt;Anchor-link 4&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="/page1#anchor5"&gt;Anchor-link 5&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href="/page2"&gt;Page 2&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="/page3"&gt;Page 3&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="/page4"&gt;Page 4&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;  
  &lt;/div&gt; &lt;!-- /#sidebar-left --&gt; 
  
  &lt;div id="content"&gt;
  &lt;div class="chapter"&gt;
  &lt;a name="anchor1" id="anchor1"&gt;&lt;/a&gt;&lt;!-- named-anchor --&gt;
  &lt;h3&gt;Sub-heading&lt;/h3&gt;
  &lt;p&gt;Lots of text&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;div class="chapter"&gt;
  &lt;a name="anchor2" id="anchor2"&gt;&lt;/a&gt;&lt;!-- named-anchor --&gt;
  &lt;h3&gt;Sub-heading&lt;/h3&gt;
  &lt;p&gt;Lots of text&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;div class="chapter"&gt;
  &lt;a name="anchor3" id="anchor3"&gt;&lt;/a&gt;&lt;!-- named-anchor --&gt;
  &lt;h3&gt;Sub-heading&lt;/h3&gt;
  &lt;p&gt;Lots of text&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;div class="chapter"&gt;
  &lt;a name="anchor4" id="anchor4"&gt;&lt;/a&gt;&lt;!-- named-anchor --&gt;
  &lt;h3&gt;Sub-heading&lt;/h3&gt;
  &lt;p&gt;Lots of text&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;div class="chapter"&gt;
  &lt;a name="anchor5" id="anchor5"&gt;&lt;/a&gt;&lt;!-- named-anchor --&gt;
  &lt;h3&gt;Sub-heading&lt;/h3&gt;
  &lt;p&gt;Lots of text&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;/div&gt; &lt;!-- /#content --&gt; 
  &lt;/div&gt; &lt;!-- /#main --&gt; 
  &lt;/div&gt; &lt;!-- /#page --&gt;&lt;/body&gt;
  </code></pre>