IE doesn't preserve changes made by javascript when Back button is clicked

L

lucyh3h

Hi,

In one of my pages, I use javascript (AJAX) to populate one mulitple
select field based on user's click event on another control. I noticed
that when I navigate back to this page by clicking browser's "Back"
button, the changes made to the multiple select is not preserved. (It
shows the initial value). While all the other user selections are
preserved.
Firefox seems fine.
How do I workaround this issue for IE?

Thanks!
Lucy
 
S

shimmyshack

Hi,

In one of my pages, I use javascript (AJAX) to populate one mulitple
select field based on user's click event on another control. I noticed
that when I navigate back to this page by clicking browser's "Back"
button, the changes made to the multiple select is not preserved. (It
shows the initial value). While all the other user selections are
preserved.
Firefox seems fine.
How do I workaround this issue for IE?

Thanks!
Lucy

You notice that in /your/ browsers (versions x on OS y) the field
values are preserved, this is not guaranteed behaviour for many
browsers.
If this page forms part of a multiple form, then clicking back could
weel be part of the "expected usage" for a user, otherwise I would say
once submitted, I don't mind if the values are not there.
You could use an onload to see if the user has set the preference for
the control that is preserved, and use that to populate the multiple
select. (if that is what you mean by initial value)
The alternative is to actually use server side code to force every
browser to be consistent by hard coding into the markup the (filtered
and validated) results of the submission the user made before clicking
back. This way whether they press back, or browse around suddenly to
other parts of the site without completely filling in the form, and
then decide to go back and carry on fillin gin the form, they will be
plesantly surprised.
Of course there are more cases that this, if the user isn't known to
you (not logged in) and their browser crashes, or if the user kills
the browser, then firefox might preserve the data if you are lucky
whereas ie won't, you can get round this by setting a cookie which
contains the values that have been filled so far, and that the server
hasn't told the user-agent to delete from the cookie yet, this should
be a temporary cookie. If your user is known to you, when they sign
back in after a crash, you could use the use the orphaned values from
their last session (if you code a bit of server logic) to allow them
to resume, again something to watch in terms of security, but it is
similar to "remember me" but with less scope and therefore less
surface area of attack.
 
L

lucyh3h

You notice that in /your/ browsers (versions x on OS y) the field
values are preserved, this is not guaranteed behaviour for many
browsers.
If this page forms part of a multiple form, then clickingbackcould
weel be part of the "expected usage" for a user, otherwise I would say
once submitted, I don't mind if the values are not there.
You could use an onload to see if the user has set the preference for
the control that is preserved, and use that to populate the multiple
select. (if that is what you mean by initial value)
The alternative is to actually use server side code to force every
browser to be consistent by hard coding into the markup the (filtered
and validated) results of the submission the user made before clickingback. This way whether they pressback, or browse around suddenly to
other parts of the site without completely filling in the form, and
then decide to gobackand carry on fillin gin the form, they will be
plesantly surprised.
Of course there are more cases that this, if the user isn't known to
you (not logged in) and their browser crashes, or if the user kills
the browser, then firefox mightpreservethe data if you are lucky
whereas ie won't, you can get round this by setting a cookie which
contains the values that have been filled so far, and that the server
hasn't told the user-agent to delete from the cookie yet, this should
be a temporary cookie. If your user is known to you, when they signbackin after a crash, you could use the use the orphaned values from
their last session (if you code a bit of server logic) to allow them
to resume, again something to watch in terms of security, but it is
similar to "remember me" but with less scope and therefore less
surface area of attack.

Thanks for your response.
The problem is IE remembers the user's selection, but the
corresponding modification using javascript is lost. Which causes
mismatched information on my page.
For example, I have two dropdown lists. Based on user's selection on
dropdown#1, I search the database and populate dropdown#2. This works
fine until user navigate back to this page using "back" button. The
selection of dropdown#1 is preserved, but the content in dropdown#2 is
set back to the default values.
I tried to use server side script, but this makes the page extremely
complicated, which I thought this is a perfact place to use AJAX...
 
S

shimmyshack

Thanks for your response.
The problem is IE remembers the user's selection, but the
corresponding modification using javascript is lost. Which causes
mismatched information on my page.
For example, I have two dropdown lists. Based on user's selection on
dropdown#1, I search the database and populate dropdown#2. This works
fine until user navigate back to this page using "back" button. The
selection of dropdown#1 is preserved, but the content in dropdown#2 is
set back to the default values.
I tried to use server side script, but this makes the page extremely
complicated, which I thought this is a perfact place to use AJAX...

so did you try the onload?

What you need to do is use server sessions to set the initial values
of the form fields when the page loads. The same ajax scripts, just
with an init method instead of assuming the user hasn't been before.
The server session simply puts its value in that javascript. 2 lines
of code, perhaps 1
 
R

Richard Maher

Hi,

shimmyshack said:
so did you try the onload?

What you need to do is use server sessions to set the initial values
of the form fields when the page loads. The same ajax scripts, just
with an init method instead of assuming the user hasn't been before.
The server session simply puts its value in that javascript. 2 lines
of code, perhaps 1

FWIW, if you use Frames, when you "go back" (hide the second frame and make
the first frame visible again) all is as you left it, or as page 2's
javascript modified it, as the case may be.

Cheers Richard Maher
 
H

Hardono Arifanto

Hi,




clickingback. This way whether they pressback, or browse around suddenly to> > > other parts of the site without completely filling in the form, and

signbackin after a crash, you could use the use the orphaned values from






FWIW, if you use Frames, when you "go back" (hide the second frame and make
the first frame visible again) all is as you left it, or as page 2's
javascript modified it, as the case may be.

Cheers Richard Maher

Or IFRAME since you don't need to change the overall layou of your
page.

Regards,
Hardono Arifanto
 
L

lucyh3h

Or IFRAME since you don't need to change the overall layou of your
page.

Regards,
Hardono Arifanto
-----------------------http://sodeve.net- Hide quoted text -

- Show quoted text -

Great! Thanks all for the response.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top