Preserve dynamically changed HTML on back button

前端 未结 5 2024
忘掉有多难
忘掉有多难 2020-12-04 09:31

It\'s amazing, I constantly see this working in other sites but never in sites that I\'m working on.

I\'m bringing in new content with ajax, I know about history.js

5条回答
  •  忘掉有多难
    2020-12-04 09:44

    Local storage is one way, another way is server side persistence.

    When the HTML is edited / created / some property is changed on the client side, you need to sync the state change of your page with webstorage or a database via a restful api (or something comparable).

    When you return to the page - the page can retrieve stored info from local storage... If you're using server-side persistence, you'll need to use it in conjunction with a session cookie to retrieve the user's state changes - which can then be loaded from the server.

提交回复
热议问题