Need a way to get the scroll box back after page refresh

I am writing a game in PHP / Zend Framework and Facebook JavaScript. The playing field is displayed in the scroll window. To view the entire game stand, the user must scroll through the page. Each step of the game causes a page refresh, so when the user moves to another step, their scroll position is lost, and the window returns to the default position. I am wondering if there is a way to automatically return this scroll window to the position it was in before the page was refreshed so that the user does not need to scroll back to where they were? Thanks!

+3
source share
3 answers

If you are creating a link-based game, I would use AJAX to send your click data to your server, process it and return it to the user without refreshing the page at all.

This will not allow you to navigate the page using JS, and it will also make the game much faster and more enjoyable for users.

+3
source

Save the position in onunload (or after each scroll event) in Window.name or in a cookie, and then scroll to that point when the page loads.
But the Ajax solution is the best approach to what you do.

+2
source

<a name="game"> gamePage.html#game

0

Source: https://habr.com/ru/post/1717893/


All Articles