473,463 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Any way to identify/capture back button event?

Hi all,

I have a problem in my web-app wherein I need to get the latest page
from server on clicking of back button..

I know that it can be done by preventing/disabling the cache in jsp as

<%
response.setHeader("Cache-Control","no-cache") ;// HTTP 1.1
response.setHeader("Pragma","no-cache");// HTTP 1.0
response.setDateHeader("Expires", -1);
%>

But that shows the ugly browser message asking if I want to repost the
information since most of the pages are POST..

To avoid this I came across the following script in jsp and javascript
that uses cookies and tries to reload the page from server if it is
found from cache..

<%Cookie mycookie = new Cookie("FromValue","Server");
response.addCookie(mycookie);
%>
<html>
<head>
</head>
<body>
<H3>This is a test for documents being pulled from the cache</H3>
<p></p>
<a href="http://www.google.com"> Click here to go to a different page,
then use the Back button to come back to this page.</a>
<script language=javascript>
function winload()
{
//alert("Load "+document.cookie);
var aCookie = document.cookie.split(";");
var value;
for (var i=0; i < aCookie.length; i++)
{
// a name/value pair (a crumb) is separated by an equals sign

var aCrumb = aCookie[i].split("=");
alert(aCrumb[0]+"="+aCrumb[1]);
if (aCrumb[0] == "FromValue") {

value = unescape(aCrumb[1]);
break;
}
}
//alert(value);
if ((value != null) && (value == "Cache"))
{
alert("Reloading from server ... ");
location.reload(true);
//location.href=location.href;//
}
}

function winunload()
{
var val = "Cache";

document.cookie = "FromValue=" + escape(val) + ";";

}
window.onload = winload;
window.onunload = winunload;
</script>
</body>
</html>

This page works fine in Internet Explorer but gives a problem in
Firefox...it actually goes in a sort of infinite loop in the
load/onload events..and have not been able to correct it..Is there any
other way a back button event can be detected?

Please reply asap,

Thanks,
Vivek Jani

Apr 3 '06 #1
3 21904
Vivek wrote:
I have a problem in my web-app wherein I need to get the latest page
from server on clicking of back button..

I know that it can be done by preventing/disabling the cache in jsp as

<%
response.setHeader("Cache-Control","no-cache") ;// HTTP 1.1
response.setHeader("Pragma","no-cache");// HTTP 1.0
response.setDateHeader("Expires", -1);
%>
No, it cannot. Read RFC1945 and RFC2616 (again).
But that shows the ugly browser message asking if I want to repost the
information since most of the pages are POST..

To avoid this I came across the following script in jsp and javascript
that uses cookies and tries to reload the page from server if it is
found from cache..


Use the proprietary approach posted a few days ago if you must.
Use server-side sessions otherwise.
PointedEars
Apr 3 '06 #2
Hi Thomas,

Thanks for ur reply..

Thomas :Use the proprietary approach posted a few days ago if you must.
Use server-side sessions otherwise.

Can u please give me the link for the proprietary approach that you are
talking about? I am not able to find the post(actually what query
should i use to find it?)

Thanks,
Vivek Jani

Apr 5 '06 #3
Vivek wrote:
Thanks for ur reply.. ^^
Thanks in advance for not posting like a complete idiot.

<URL:http://jibbering.com/faq/faq_notes/pots1.html>
<URL:http://www.safalra.com/special/googlegroupsreply/>

[repaired quotation]
Use the proprietary approach posted a few days ago if you must.
Use server-side sessions otherwise.


Can u please give me the link for the proprietary approach that you are

^ talking about? I am not able to find the post(actually what query
should i use to find it?)


Try "onunload" and "Firefox", I do not remember exactly either.
PointedEars
Apr 5 '06 #4

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

Similar topics

1
by: Matthew Wieder | last post by:
Hi - I wanted to capture the enter button on a form since I have a datagrid with the first column being a delete button and if someone hits enter it deletes the first record. I coded: private...
7
by: Amadelle | last post by:
Hi all and thanks in advance, I am stuck! I can't figure out how to identify which button was clicked on my ASP.NET page in the PostBack event? So what I am trying to do is to is to have an if...
4
by: Bill Manring | last post by:
I need to capture the event when the user closes the browser in my application. I have some code in the session_End event, which works fine when the session times out, but I need to end the...
5
by: ewillyb | last post by:
Hi, ASP.NET has some interesting behavior when the user hits the Enter key. If there are multiple ASP:Buttons (rendered as HTML submits) on the form, when the user hits enter, the first button's...
8
by: Ken Sturgeon | last post by:
I have a button inside a panel control. Apparently I can't expect VB to respond to the button's _Click event. How do I capture the click event? Thanks Ken
1
by: karthik juneni | last post by:
Hi all, Iam trying to capture windows closing event (i.e) when the user clicks on the "X" button i want to capture that event and want to update some values in the database.I tried two methods...
6
by: yossico | last post by:
Hi, I have a question which is related to an old question submitted in this forum but was not fully answered. The original question is at Any way to identify/capture back button event? . ...
7
by: Lit | last post by:
Hi, How can I capture the vertical scroll bar position for a Listbox. I have a Listbox of 100 items + when I click on it I post back remove the item selected. After returning to the client...
1
by: bravo | last post by:
hi using javascript i am able to capture the backspace key and also to disable it but it is not working for the back button on the toolbar. i am new to javascript have searched a lot but didnt...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.