title: Detect change in hash value of URL using JavaScript
body: <p>I'm working on a simple application which is single page based (due to project restrictions) and has dynamic content. I understand the dynamic content alright but what I don't understand is how to set-up a script that changes the html of a <code>div</code> when the hash value in the URL changes.</p>
  
  <p>I need a JavaScript script to work as such:</p>
  
  <p>Url: <code>http://foo.com/foo.html</code> div contents: <code>&lt;h1&gt;Hello World&lt;/h1&gt;</code></p>
  
  <p>Url: <code>http://foo.com/foo.html#foo</code> div contents: <code>&lt;h1&gt;Foo&lt;/h1&gt;</code></p>
  
  <p>How would this work?</p>
  
  <p>Please help! Thanks.</p>