473,804 Members | 3,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Preserving state

This might not really be a javascript question, but I'll start with this
group.

At http://www.gazingus.org/ there is a very nice collapsible menu written
using CSS and Javascript

Using Lists for DHTML Menus
HTML lists, along with well-placed CSS and JavaScript, result in flexible
dynamic menus that gracefully degrade in older browsers.<<<<<< <

Does anyone have any ideas as to how I might go about modifying the code so
that the menu will remember its open/close state from one screen refresh to
the next.

TIA


Jul 20 '05 #1
6 1804
Also sprach Karl:
Does anyone have any ideas as to how I might go about modifying the
code so that the menu will remember its open/close state from one
screen refresh to the next.


There are three ways of preserving information across page loads/refreshes:

1) Put the info in the query string, like
"mypage.html?me nu1=open&menu2= closed", but that will not work for refreshes,
as you must explicitly set the query string. But you could use it with menu
links which you would then have to generate dynamically or modify their
query string property with JavaScript. However, this would be quite a
complicated solution.

2) Set a cookie. Disadvantage: will not work if users have cookies disabled.
But otherwise this seems to be the simplest solution.

3) Embed your page in a frameset and store the info there. If you are using
frames anyway, this would be *the* solution for you. If your site is
frameless, you may frame it in a frame stretching over the whole window.
This way, you could even avoid some frame-related problems.

4) Use the onunload event to "redirect" to the same page with the query
string set. (This is probably the worst solution as you are thereby
preventing your visitors from ever leaving your site.)

My conclusion: Use cookies for a frameless page and the top level frame for
a page using frames. But then: is it really that bad if your menu reappears
closed upon refresh? Another possibility might be to implement the menu in
such a way that the menu, "onload", figures out by itself which main page is
being shown and opens itself accordingly.

Jul 20 '05 #2
Thomas Mlynarczyk wrote:
3) Embed your page in a frameset and store the info there. If you are using
frames anyway, this would be *the* solution for you. If your site is
frameless, you may frame it in a frame stretching over the whole window.
This way, you could even avoid some frame-related problems.


What problems with frames you can avoid with this are you writing
about? With frames you can only get more in trouble than without
them. Making bookmarking worse is only one of the prob^W challenges
you will encounter then. For I know you understand German, read

http://www.subotnik.net/html/frames.html
PointedEars
Jul 20 '05 #3
Also sprach Thomas 'PointedEars' Lahn:
3) Embed your page in a frameset and store the info there. If you
are using frames anyway, this would be *the* solution for you. If
your site is frameless, you may frame it in a frame stretching over
the whole window. This way, you could even avoid some frame-related
problems.
What problems with frames you can avoid with this are you writing
about? With frames you can only get more in trouble than without
them. Making bookmarking worse is only one of the prob^W challenges
you will encounter then.


The actual problem that arises with regard to bookmarking is that you might
accidentally bookmark the "menu" frame, or that you will end up with an
unframed page (where vital elements such as the navigation) are missing -
this also happens when you get to the page from a link found in a search
engine. As for bookmarking itself (as well as printing a web site by the
way) I have always been of the opinion that the correct handling of this is
entirely the browser's responsibility. If a browser supports frames, the
manufacturer could easiliy implement a correct handling of bookmarks which
takes into account the special needs of framesets. Besides, users should
know how to handle their own user agent.

But to get back to the point: Normally, when someone clicked a link to one
of your subpages, you would use JavaScript to load the frameset. A problem
arises, when the user has JavaScript disabled. But in the case we have here,
it seems that the site relies upon JavaScript and even if it did not, the
user would not notice any difference as there would be just one frame
stretching over all the window and the actual frameset would be a mere
"backstage" technical structure. So the problem of loading the frameset
(which includes bookmarking) would not appear in this case as the frameset
would not contribute to the visual presentation but just serve as a storage
device for JavaScript data.

Of course: If a page is designed frameless, it would not be very elegant to
add a "blind" frameset just for the sake of storing variables. In such a
case I would not recommend the frame solution. But if the OP uses frames
anyway (I don't know if he does), the frameset would indeed be the perfect
place to store the data.
http://www.subotnik.net/html/frames.html


I know this one - and many others like it. I've read them, thought about
them and all in all I have now - I think - a very good understanding
concerning frames, their use, their advantages and disadvantages as well as
problems which must be solved when using them.

Jul 20 '05 #4
Thomas Mlynarczyk wrote:
Also sprach Thomas 'PointedEars' Lahn:
3) Embed your page in a frameset and store the info there. If you
are using frames anyway, this would be *the* solution for you.
If your site is frameless, you may frame it in a frame stretching
over the whole window. This way, you could even avoid some
frame-related problems.
What problems with frames you can avoid with this are you writing
about? With frames you can only get more in trouble than without
them. Making bookmarking worse is only one of the prob^W
challenges you will encounter then.


The actual problem that arises with regard to bookmarking is that you
might accidentally bookmark the "menu" frame,


No, the problem is that without a context menu, in graphical browsers
you can only bookmark the frameset.
I have always been of the opinion that the correct handling of this
is entirely the browser's responsibility.
The UA knows only the URI of the frameset if one selects "Add To
Bookmarks" from the main menu. That is likely to happen here since
the user does not expect that he is required to use the context menu
of the frame, if there is any.
But to get back to the point: Normally, when someone clicked a link
to one of your subpages, you would use JavaScript to load the
frameset.
I have done that until a month before, but I am not doing it any longer.
Instead, I write a link dynamically for visitors to reload the frameset
*if* they want that. Never serve what has not been ordered.
A problem arises, when the user has JavaScript disabled.
But in the case we have here, it seems that the site relies upon
JavaScript
So bad design justifies worse design?
and even if it did not, the user would not notice any
difference as there would be just one frame stretching over all the
window and the actual frameset would be a mere "backstage" technical
structure.
Visitors will note a difference when they look into the Location Bar.
They will never know which part of a website they navigated to, unless
you provide breadcrumbs or stuff like that in *every* (frame) document.
So-called "cloaking" is a Bad Thing and should be discarded/disabled.
So the problem of loading the frameset (which includes bookmarking)
would not appear in this case
True.
as the frameset would not contribute to the visual presentation but
just serve as a storage device for JavaScript data.
Definitely wrong.
Of course: If a page is designed frameless, it would not be very
elegant to add a "blind" frameset just for the sake of storing
variables. In such a case I would not recommend the frame solution.
But if the OP uses frames anyway (I don't know if he does), the
frameset would indeed be the perfect place to store the data.


The perfect solution is to remove the frameset if there is one and
there is something better (CSS overflow:scroll for example, I am
currently working on that). A suboptimal solution will at least
include a no-frames part so that if frames are disabled (Opera can
do that) or not even supported, one gets useful and usable content.

I would rather bother with cookies if properly explained than bother
with a site which documents I cannot bookmark (from the newbie
perspective) only because the author is incompetent enough not to use
server-side sessions to store his settings (from the professional
perspective).
PointedEars
Jul 20 '05 #5
Hi,

I am aware of the 'age' of this post but I thought I would ask the question
nonetheless (no i've already got ;))

Thomas Mlynarczyk wrote:
3) Embed your page in a frameset and store the info there. If you are using
frames anyway, this would be *the* solution for you. If your site is
frameless, you may frame it in a frame stretching over the whole window.
This way, you could even avoid some frame-related problems.

Using simple things like strings this would work but have you ever tried
this using IE5+ and an object like table?

Thx,
Fermin DCG
Jul 20 '05 #6
F. Da Costa wrote:
Thomas Mlynarczyk wrote:
3) Embed your page in a frameset and store the info there. If you are using
frames anyway, this would be *the* solution for you. If your site is
frameless, you may frame it in a frame stretching over the whole window.
This way, you could even avoid some frame-related problems.


Using simple things like strings this would work but have you ever tried
this using IE5+ and an object like table?


What do you mean? What is "an object like table"?

The type of data to be stored in the frameset "window" object's property
does not matter, not even in IE 5+. What matters is whether the DOM
allows you to add properties to the frameset's "window" object, if there
is any, or not. (In IE 5+ it does.) But that does not make this bad
approach of preserving data while navigating any better.
PointedEars

P.S.
Please separate quote and new text by an empty line which makes your
postings more legible.
Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1966
by: A.Kelly | last post by:
Two problems that I'm having (due to being a n00bie) are: The form I'm using is the basic form with a username, email address etc.. the two that I'm most concerned about are the Gender, and State form entries. Gender is of course two radio buttons. <input name="gender" type="radio" id="male" value="M"> M <input name="gender" type="radio" id="female" value="F">F
2
2479
by: Dave | last post by:
Hello all, I have three vector<int> v1, v2 and v3. I want to copy everything from v1 to v3, except for the items that are also in v2. This sounds tailor-made for set_difference() but for one catch: I need the order preserved, which set_difference() does not do. As it stands now, I copy v1 to v3, manually loop over v2 and, for each element in v2, remove the first occurrence (if any) of that element from v3.
2
2851
by: cefrancke | last post by:
I have a form (no underlying record set) that has two separate sub-forms on it. Each sub-form has data from two different tables. Above each sub-form there is one unbound combo box with a SQL record source that returns an ID field and a Text field. Next to each combo box is two buttons, one that 'Applys' the filter of the sub-form to the value in the combo box and one that 'Clears' the form's current filter. When the click event of the...
16
5149
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. And K&R2 mentions "signed extension" everywhere. Reading some old clc posts, I've beginning to realize that these books are over-generalizing the topic. I am just wondering what the difference between the following pairs of terms are: 1)...
3
1867
by: craigkenisston | last post by:
Hi, I am programming a classical registration form using asp.net. I have the country list and a list of all states for each country in a database. I already have this working code in which if the user selects a country I populate a list with the states/provinces for that country, the dropdown for the countries is set to autopostback.
2
1784
by: GHQ Dev | last post by:
I have an aspx page (page1.aspx) that post back to another aspx page (page2.aspx) “page2.aspx” has a button called back, when the user click on this button it is supposed to return to “page1.aspx”, when the user returns to “page1.aspx” I want to restore the viewstate of the page so the page would have the same data as the user left it. How can I achieve this behavior? Thanks
0
1491
by: rlueneberg | last post by:
I am having difficulty with preserving field values in a DetailsView control after clicking the insert button event. protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e) { e.KeepInInsertMode = true; GridView1.DataBind(); } What I noticed is if I click in a button outside DetailsView it does
3
1671
by: Finder | last post by:
Hi, Can anyone please help me with the following problem that i am having? Basically i have a form containing Few fields like name age country,state. After Filling the name , age and i selecting Drop down box of country the auto select of state is changes the value based on country. when it changes the page is refreshed and all information above in name ,age is disappred. can any one tel me how to preserve those values ?
3
3304
by: sophia.agnes | last post by:
Dear all, I was going through the book "C a software engineering approach by darnell & Margolis" there was a section named sign preserving vs value preserving it is as follows sign preserving rule:- when signed and un signed objects meet in an expression, the result is
0
9569
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9130
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2975
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.