Je vois beaucoup de personnes recommandent le hidden- iFrame
hack qui est jQuery history plugin mais tout ce que je vraiment besoin est l'autre moitié de cette technique:Comment ajouter un état d'historique du navigateur?
function whenItemIsClicked()
{
window.location.hash = this.id;
//some other stuff, like Ajax
}
//and then, if page is reloaded...
$(document).ready(function(){
var loc = window.location.hash;
//if there happens to be a hash, navigate to corresponding content
if(loc != '') $(loc).click();
});
Ces deux grand travail. Maintenant, je voudrais joindre ces deux lignes
var loc = window.location.hash;
if(loc != '') $(loc).click();
à un événement, mais il semble qu'il n'y ait pas un qui sera déclenchée systématiquement par le bouton de retour. Existe-t-il un moyen d'ajouter un état de l'historique du navigateur qui sauvegardera l'URL actuelle afin que la technique ci-dessus fonctionne?