Persist javascript variables between GET requests?

后端 未结 4 545
-上瘾入骨i
-上瘾入骨i 2021-01-22 09:31

ASP .NET is allowed
Storing the values in hidden input fields is allowed
Query String is not allowed
POST request is not allowed

It is possible to store J

4条回答
  •  我在风中等你
    2021-01-22 10:01

    At the moment using cookies is your best bet. You can serialize the JavaScript objects to strings, and unserialize them back into objects later. A good choice format is JSON, since it is a subset of JavaScript.

    There is also storing objects in Flash. Storing in Google Gears. DomStorage

    See this library that has an interface to each: http://pablotron.org/?cid=1557

    If you are in control of all aspects of the page, then you can also wrap the page in a top level frame. Then only refresh the child frame. You can then store content in the parent frame.

    You can see this used in sites like GMail, and others where the only thing that changes in the URL is outside the #.

    You don't even have to change the URL, that part is just put in for Human Friendly URLs. (So you can actually copy and paste URLs as is).

提交回复
热议问题