The content the user left last time will be automatically restored and the website will jump to that content
P粉5877801032023-09-13 19:14:01
0
1
543
In HTML and CSS, how can I make it so that when a user leaves and reopens the page after viewing it, the page will be loaded in the paragraph that the user last focused on?
It’s impossible to do this with just HTML and CSS. But it is possible using front-end JavaScript and cookies.
Regularly save the scrollTop and scrollLeft of the main content element to the document cookie. When the document loads, parse the cookie and use the scrollTo method to resume scrolling.
It’s impossible to do this with just HTML and CSS. But it is possible using front-end JavaScript and cookies.
Regularly save the scrollTop and scrollLeft of the main content element to the document cookie. When the document loads, parse the cookie and use the scrollTo method to resume scrolling.