le bouton de retour du navigateur ne fonctionne pas dans un environnement en cache
Question
Le bouton Précédent provoque l'actualisation de ma page. Peut-on contourner ce problème sans désactiver le cache?
La solution
Essayez d'ajouter ceci à votre en-tête HTML:
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
Autres conseils
où vous cliquez sur produit / image sur la page, appelez la fonction javascript onclick i.e.
function getHashOnBack(valueget)
{
location.hash = "#backTo=" + $(window).scrollTop();$(document).height();
}
Maintenant, mettez
$(document).ready(function ()
{
var ab = window.location.hash.substring(1).split("=");
if (ab[0] == "backTo")
{
// this would be called automatically when back putton pressed and hav #back=1234 etc. // value in url
$(window).scrollTop(parseInt(ab[1]));
}
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow