Navigating back to Search Page with same state (JavaScript)

前端 未结 2 599
一向
一向 2021-01-23 09:47

How do I, using JavaScript, retain the state of the search page, when a user clicks into a search result, but then goes back to the main search page.

e.g.

2条回答
  •  梦谈多话
    2021-01-23 10:40

    You can simply do it by saving the data in users device . You can do it by using cookies or by localStorage. I prefer localStorage because users can deny cookies easily. Like this-

    localStorage.setItem("tags",tagItemsInAnArray);
    

    And laterlocalStorage.getItem("tags");

提交回复
热议问题