Hello I am trying to create a refresh script to refresh a page on incomming messages,updated posts,ect. Why is x,y not executed useing ex: 1? I have seen a few different methods of reloading a page and keeping scroll position but they seem overkill. I think I would like to use ex: 2, is there any logical way to clear the server side variables using reload() or should I go another route for something like this?
<script>
function Refresh()
{
var x = window.pageXOffset;
var y = window.pageYOffset;
//ex 1:this works but doesnt keep scroll position
//window.location = window.location.href;
//ex 2: this works and retains x,y but doesnt refresh $_POST $_GET server side variables
window.location.reload();
window.location.scrollTo(x,y);
}
//for testing only
setInterval('Refresh()', 5000);
</script>
Why does this script not execute scrollTo(x,y) javascript?
Aucun commentaire:
Enregistrer un commentaire