Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How can we stop IE from executing javascript on a back button click

Reply
Thread Tools

How can we stop IE from executing javascript on a back button click

 
 
Tom
Guest
Posts: n/a
 
      11-14-2007
Basically I have a page that I load with 10 input fields. If users
have JS enabled I want to hide 5 of these fields so as to reduce
clutter. If the user needs these extra fields an "Add" button can be
used to display the hidden fields one by one.

Once the fields a filled in the user submits them for validation and
if there are any error They can "Go back" to make some changes. The
whole process works great in FF & Opera but IE lets me down because if
you use the Browser "Back" button the Javavscript gets executed even
though it should be loaded out of cache.

An simple example to the my problem across can be found at
http://tommydiy.freehostingnow.com/backcache.html

Any suggestion greatly appreciated.
Tom

 
Reply With Quote
 
 
 
 
Tom
Guest
Posts: n/a
 
      11-14-2007
One idea I was toying with was too add a parameter to the URL
represented by history.previous by it seems to be forbidden to try to
manually manipulate this value.


 
Reply With Quote
 
 
 
 
Ian Hobson
Guest
Posts: n/a
 
      11-23-2007
Hi Tom,

Tom wrote:
> Basically I have a page that I load with 10 input fields. If users
> have JS enabled I want to hide 5 of these fields so as to reduce
> clutter. If the user needs these extra fields an "Add" button can be
> used to display the hidden fields one by one.

A good, helpful way to use JS.
>
> Once the fields a filled in the user submits them for validation and
> if there are any error They can "Go back" to make some changes. The
> whole process works great in FF & Opera but IE lets me down because if
> you use the Browser "Back" button the Javavscript gets executed even
> though it should be loaded out of cache.
>
> An simple example to the my problem across can be found at
> http://tommydiy.freehostingnow.com/backcache.html
>
> Any suggestion greatly appreciated.
> Tom
>

Hi Tom,

I think it is a good idea NOT to ask your users to go back - they often
find there is no data in the fields they entered when they do go back
and they have to enter it all in again.

And that is a way to **** off your users in a major way. In a business
context, it also upsets the person paying their wages.

So....

Record the status of the open/closed fields in a hidden field, so it is
sent with the POST.

After validation, the script handling the POST should either

a) If the data is valid, update the database and use a "location" header
to redisplay the data in show mode. This produces a display of the data
stored, not a redisplay of the data the user just sent).

b) If the data is invalid, build the next (response) screen exactly as
on initial "show" request, but including all the error messages set up
in validation and the data you have from the POST (instead of data from
the database read). It is easy to use the same code so this is "no cost".

OK - I am assuming you show the data to the users with a "Edit" button,
so they have confidence they have not changed anything if the don't
click "Edit". I find this is a good idea also

When you send the response the "onload" event can open or close the
fields as required - you have the data to set a parameter for this.

That way the users don't have to go back when they make an error.

And ALL error messages are shown on the screen - not one at a time or on
another screen.

And they can be near the field that is in error.

But wait - there is more...

If your visitor goes on elsewhere and comes back to the response page
they will NOT be presented with the warning about repeating the POST!
(To get that they would have to go back FROM the history list. And there
is no reason for them to do that.) A simple back fro the response
screen reloads it again. This removes possible double updates which
could damage the database, without inconveniencing your users at all.

And as your final bonus...

You also avoid many character set conversion problems. You won't find
that the show of saved data does not include the same character
conversions as you have stored in your database. I.e. the "show" after
save is different from the "show" of freshly read data from the database.

Until I worked out the location header trick I was forever getting back
slashes doubled up every edit, and £ characters would gain A-acutes -
but these problems did not appear on the response page, only later.

Regards

Ian
 
Reply With Quote
 
Tom
Guest
Posts: n/a
 
      11-27-2007
Thanks for your reply Ian,

I will digest your recommendations and see what I come up with.

Thanks for the extensive input. You are really selling your point

Tom

On Nov 23, 4:42 pm, Ian Hobson <ian.hob...@ntlworld.com> wrote:
> Hi Tom,
>
> Tom wrote:
> > Basically I have a page that I load with 10 input fields. If users
> > have JS enabled I want to hide 5 of these fields so as to reduce
> > clutter. If the user needs these extra fields an "Add" button can be
> > used to display the hidden fields one by one.

>
> A good, helpful way to use JS.
>
> > Once the fields a filled in the user submits them for validation and
> > if there are any error They can "Go back" to make some changes. The
> > whole process works great in FF & Opera but IE lets me down because if
> > you use the Browser "Back" button the Javavscript gets executed even
> > though it should be loaded out of cache.

>
> > An simple example to the my problem across can be found at
> >http://tommydiy.freehostingnow.com/backcache.html

>
> > Any suggestion greatly appreciated.
> > Tom

>
> Hi Tom,
>
> I think it is a good idea NOT to ask your users to go back - they often
> find there is no data in the fields they entered when they do go back
> and they have to enter it all in again.
>
> And that is a way to **** off your users in a major way. In a business
> context, it also upsets the person paying their wages.
>
> So....
>
> Record the status of the open/closed fields in a hidden field, so it is
> sent with the POST.
>
> After validation, the script handling the POST should either
>
> a) If the data is valid, update the database and use a "location" header
> to redisplay the data in show mode. This produces a display of the data
> stored, not a redisplay of the data the user just sent).
>
> b) If the data is invalid, build the next (response) screen exactly as
> on initial "show" request, but including all the error messages set up
> in validation and the data you have from the POST (instead of data from
> the database read). It is easy to use the same code so this is "no cost".
>
> OK - I am assuming you show the data to the users with a "Edit" button,
> so they have confidence they have not changed anything if the don't
> click "Edit". I find this is a good idea also
>
> When you send the response the "onload" event can open or close the
> fields as required - you have the data to set a parameter for this.
>
> That way the users don't have to go back when they make an error.
>
> And ALL error messages are shown on the screen - not one at a time or on
> another screen.
>
> And they can be near the field that is in error.
>
> But wait - there is more...
>
> If your visitor goes on elsewhere and comes back to the response page
> they will NOT be presented with the warning about repeating the POST!
> (To get that they would have to go back FROM the history list. And there
> is no reason for them to do that.) A simple back fro the response
> screen reloads it again. This removes possible double updates which
> could damage the database, without inconveniencing your users at all.
>
> And as your final bonus...
>
> You also avoid many character set conversion problems. You won't find
> that the show of saved data does not include the same character
> conversions as you have stored in your database. I.e. the "show" after
> save is different from the "show" of freshly read data from the database.
>
> Until I worked out the location header trick I was forever getting back
> slashes doubled up every edit, and £ characters would gain A-acutes -
> but these problems did not appear on the response page, only later.
>
> Regards
>
> Ian


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to fire both event button click and textchanged when button is click and text is changed Amy ASP .Net 0 06-01-2006 02:33 PM
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Building Controls 1 05-28-2004 06:23 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57