Marcus Edensky
Marcus Edensky

Reputation: 944

Remembering scroll position in all pages with PHP session when using menu buttons

My page has a horizontal top menu bar with a logo at the top of it. Because of the logo, visitors will scroll down slightly. When using the menu, I don't want the page to annoyingly jump up to the top.

How can I maintain the window scroll position when the visitor clicks another top menu button only, throughout the whole page?

Upvotes: 0

Views: 899

Answers (1)

nobody
nobody

Reputation: 10645

"My page has a horizontal top menu bar with a logo at the top of it. Because of the logo, visitors will scroll down slightly"

Isn't that frustrating for the user? and the solution you are suggesting makes things even worse and more weird, I think you seriously need to reconsider your design.

However if you insist on your solution you should use JavaScript, read the window.ScrollY store it in a cookie then read back the cookie on the new page and use window.scrollTo() function to scroll to the old position.

Upvotes: 1

Related Questions