admin管理员组文章数量:1332344
Is it possible to save the current state of a webpage so you can later restore it to that state?
Through "state" I mean everything that defines the current behavior of the page: html tags, css, JavaScript variables, form data, etc...
So you could simply have something like: savePage()
which stores all the needed data in localhost and then use loadPage()
to retrieve that data.
I guess the html
, css
and inputs value
are easy to save, but what about all the JavaScript variables on that page? Is it possible to save all the JavaScript variables held in the memory? (probably in a JSON
object).
Is it possible to save the current state of a webpage so you can later restore it to that state?
Through "state" I mean everything that defines the current behavior of the page: html tags, css, JavaScript variables, form data, etc...
So you could simply have something like: savePage()
which stores all the needed data in localhost and then use loadPage()
to retrieve that data.
I guess the html
, css
and inputs value
are easy to save, but what about all the JavaScript variables on that page? Is it possible to save all the JavaScript variables held in the memory? (probably in a JSON
object).
- No, you save your own state – Ruan Mendes Commented Aug 31, 2013 at 16:54
-
Why? Isn't it possible to get all the JavaScript variables in use by the current page? Aren't all bound to the
window
object? – XCS Commented Aug 31, 2013 at 21:33 - 1 No, many variables are hidden within closures and can't be accessed from the outside. – Ruan Mendes Commented Sep 4, 2013 at 13:36
2 Answers
Reset to default 3Essentially what you want is to resuse something when user es back,so here is my answer.
well its certainly possible.You can traverse the dom and put your stuff in to localstorage.
LocalStorage supports only string.
Use localStorage if you want the data to persist beyond browser close and SessionStorage if i want the data to persist with in the browser close.
NOTE:IE7 + support for SessionStorage and LocalStorage
It has plenty of memory as pared to cookies(4kb with 15 to 20 cookies allowed per domain).
- IE(10 mb)
- Mozzilla(5 mb)
- Chrome(2.5 mb)
Well depends, you can use localStorage to do that on the client side, or for example write a javascript function to send all variables to the server and store them there.
You need to think more about that problem.
本文标签: jquerySave current page state javascriptStack Overflow
版权声明:本文标题:jquery - Save current page state javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742326882a2453902.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论