473,387 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

Tom
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

Nov 14 '07 #1
3 2684
Tom
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.
Nov 14 '07 #2
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 piss 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
Nov 23 '07 #3
Tom
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 :p

Tom

On Nov 23, 4:42 pm, Ian Hobson <ian.hob...@ntlworld.comwrote:
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 piss 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
Nov 27 '07 #4

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

Similar topics

4
by: Guadala Harry | last post by:
Suppose I have a hyperlink that, when clicked, executes a JavaScript function on the client. Separately I have a button that, when clicked, causes a post back and executes a server-side function,...
2
by: Martyn Fewtrell | last post by:
Dear All I have a Windows 2003 Server with IIS6 where the validation controls on ASP.Net pages no longer work. I believe it to be specific to the server as if I create an ASP.Net page on the...
10
by: Jim Bayers | last post by:
We need to stop students from clicking on the form button more than once. We have a form that students fill out with their credit card information. They click, the form sends the data in xml to...
6
by: tshad | last post by:
I am trying to set up a Javascript popup box that has a way of sending back a message to asp.net on how to process some data. At the moment I am just doing: ...
7
by: jab3 | last post by:
Hello. I'm wondering if someone can answer something I'm sure has been answered a thousand times before. I am apparently just too dumb to find the answer. :) I've found information about the...
8
by: Richard Maher | last post by:
Hi, I am in a mouseup event for button A and I'd like to disable=false button B before starting some work. Is there anyway that an event for button B can then fire before my event processing for...
7
by: robin1983 | last post by:
Hi, good morning everyone, i have a file called attendence.php The problem is that some part of code is executing properly and half of the code is not and i dont get any warning or error message. For...
8
praclarush
by: praclarush | last post by:
Ok, I'm new to JavaScript and I'm taking a class for it the assignment in it I'm supposed to create edit a pre-made page to display a marquee that automatically scrolls for the user, as well as give...
2
Frinavale
by: Frinavale | last post by:
JavaScript in ASP.NET Using JavaScript in ASP.NET pages can make your application seem to work faster and prevent unnecessary calls to the server. JavaScript can be used to perform client-side...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.