<script type="text/javascript">
window.onload = function(){
setTimeout(function(){
document.getElementById('test').onclick = function(){
location.replace(window.location.hostname +'#test');//для теста
if(window.location.hash != '') {
alert(window.location.hash.substring(1));
}
return false;
};
}, 100);
};
</script>
<a href="#test" id="test">link</a>