Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Back Button

Status
Not open for further replies.

bduke

Programmer
May 17, 2002
84
US
I have a problem on using Back button on my page - What I want to be able to do is take control of the back button from the menu of IE or netscape - is there away to do this.
 
no!

but you can validate where they came from and catch that conmdition in the other pages. you can manipulate the cache settings also.

what exactely is it you want to do?

____________________________________________________
Python????? The other programming language you never thought of!
thread333-584700

onpnt2.gif
 
We have a page that we thru the pages back and forth - and one page is loaded by the submit - and that button is the last thing that was hit so it keeps loading the page - so I was wondering about doing it this way. - thanks for your help.
 
I had the same problem a few projects ago and I found the following code online... You'll have to adapt it to your purposes, but the idea is that it detects whether the page was pulled from the cache (assuming by the back button) or loaded.

Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>

<HTML>
<BODY ONLOAD=&quot;handleBackButton()&quot;>
<FORM NAME=&quot;_mine&quot;>
<INPUT NAME=&quot;_a1&quot; VALUE=&quot;1&quot; STYLE=&quot;visibility:hidden&quot;>
</FORM>
<SCRIPT LANGUAGE=&quot;JAVASCRIPT&quot;>
var x=&quot;1&quot;;
var isBack;
function handleBackButton(){
   isBack = (x != document._mine._a1.value);
   document._mine._a1.value=2;
   document._mine._a1.defaultValue=2;
}

function isBackButtonUsed(){
 return isBack;
}
</SCRIPT>
<H1>Back button testing</H1>
<form>
<input type=button value=&quot;is back button&quot; onclick=&quot;(isBackButtonUsed())?
alert('Back button was used'):alert('Page was loaded normally')&quot;>
</form>
</BODY>
</HTML>
 
If you put this at the top of the page they shouldn't be able to back into it. They'll get a message that the page has expired. Keep in mind though that you can hit the refresh button and reload it.

<%
Response.ExpiresAbsolute = #2000-01-01#
Response.AddHeader &quot;pragma&quot;, &quot;no-cache&quot;
Response.AddHeader &quot;cache-control&quot;, &quot;private, no-cache, must-revalidate&quot;
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top