Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to keep data between page loads?

22 views
Skip to first unread message

Test

unread,
Oct 3, 2012, 4:50:46 AM10/3/12
to
I have a web page that has a lengthy menu structure containing hundreds of items.
When user clicks a link the page reloads and depending on the situation a shorter
version of the list is shown to user.
Currently I am using forms and user is clicking on a:
<a target="BLAH" href="mypage.php?PARAM=125">Click this</a>

Reloading the entire structure takes time and. Is there a way to keep the
structuredata and reuse it between page loads? Cookies perhaps?

Hans-Georg Michna

unread,
Oct 3, 2012, 5:03:12 AM10/3/12
to
The most important ways to achieve this are these, as far as I
know:

1. Pull the data through the server. (I think this is what you
wanted to avoid.)

2. Stuff it into a session cookie.

3. Use the HTML5 sessionStorage.

The latter is not supported by old browsers, but it is supported
to some sufficient degree in all modern browsers.

There are some other ways, but I think these are the most widely
used ones.

Hans-Georg

Barry Margolin

unread,
Oct 4, 2012, 4:04:10 AM10/4/12
to
In article <7dun68tbrnmm17pjo...@4ax.com>,
Using cookies for such a large amount of data is not generally
recommended, since the browser has to send all the cookie data to the
server on every request.

HMTL5 local storage may be a better solution, although it won't work
with older browsers.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Jukka K. Korpela

unread,
Oct 4, 2012, 4:26:22 AM10/4/12
to
2012-10-03 11:50, Test wrote:

> I have a web page that has a lengthy menu structure containing hundreds of items.

That means a problem in usability, no matter how you implement it. But
sometimes such things may be necessary. Then the first thought should
be: can this be implemented in an application-like manner? That is, as a
"single-page application", or as an "HTML5 application", to use the
common term (which is rather misleading, since it's mainly about
JavaScript applications that operate on an HTML document tree).

> When user clicks a link the page reloads and depending on the situation a shorter
> version of the list is shown to user.

In an application-like approach, there are no page reloads. Only the
part that needs changing is changed. Maybe just "with style", as you can
hide elements with CSS. But e.g. for a select menu, you would have menu
items in a JavaScript object, and the <select> element would be
generated from it, using different setups.

> Currently I am using forms and user is clicking on a:
> <a target="BLAH" href="mypage.php?PARAM=125">Click this</a>

In an application-like approach, you would have a JavaScript-driven
button instead of a link, and clicking on the button would just set a
variable, followed by whatever updates it requires to document content.

Of course, this approach means that client-side scripting must be
enabled in the browser.

> Reloading the entire structure takes time and. Is there a way to keep the
> structuredata and reuse it between page loads? Cookies perhaps?

Well, there are frames... and they have in a sense received absolution
in HTML5 drafts, which make <iframe> a citizen of HTMLland with full
hum... I mean elemental rights. If you are very brave, you could even
use classical frames, with <frameset> and all.

But it really depends on the context and what the big picture really is.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
0 new messages