onhashchange IE8 browsing
<p>On a page that I'm making at the moment I have anchor tags that link to #'s and on hash change of the page I want to hide one div and show the other.
This works fine on all browsers I've tested on other than IE8. Chrome, Firefox and IE9 and IE 10 all work fine.
I'm looking for the best way to achieve this. A fix would be great, but the best way of achieving this effect would be great.
Here is examples of the code involved.</p>

<pre><code>&lt;body onhashchange="HashChangeHandler();"&gt;
 &lt;a href="#example"&gt;example&lt;/a&gt;
&lt;/body&gt;
&lt;script type="text/javascript"&gt;
 function HashChangeHandler(){
var url = window.location.href;
var splitURL = url.split(/#(.+)?/)[1];
$('.alldivs').hide();
$(document.getElementById(splitURL)).show();
 }
&lt;/script&gt;
</code></pre>
