Même si vos ancres ont des noms de balises uniques, lorsque vous naviguez dans l'historique du navigateur et revenez à cette ancre particulière, il ne va pas exécuter le javascript associé à l'onclick de cette ancre.
Vous devez définir Window.onhashChange pour appeler votre fonction de spectacle. Vous n'avez même pas besoin d'Onclick après le changement. J'ai testé le suivi:
<pre>
<html>
<head>
<script type="text/javascript">
window.onhashchange=window.onload=function(){
window.setTimeout(doHashCheck, 10);
}
var doHashCheck = (function(global) {
return function() {
var addr = window.location.hash.replace(/^#/,'');
show(addr);
}
})(this);
function show(addr)
{
a=new XMLHttpRequest();
a.onreadystatechange=function()
{
if (a.readyState==4 && a.status==200)
{
document.getElementById("content").innerHTML=a.responseText;
}
}
a.open("GET",addr+".php",true);
a.send(); //
}
</script>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache" />
<META HTTP-EQUIV="Expires" CONTENT="-1" />
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, no-store, must-revalidate" />
</head>
<a href="#1">Load 1.php into content</a>
<a href="#2">Load 2.php into content</a>
<a href="#3">Load 3.php into content</a>
<a href="#4">Load 4.php into content</a>
<!-- Load content here-->
<div id="content"></div>
</body>
</html>
</pre>