House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

detecting back button for page refresh

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Protoculture
05/03/2005 11:05 AM

Hi All. I would like to detect that the user has clicked the back button. I need to do this in order to get the last value entered in the form. ( currently using session variables to recall the last item searched for ). However as you can guess, by pressing the back button you do not get the lastest session items, you get the old ones. any work arounds?

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rebecca Wells
05/03/2005 12:30 PM

You could try this: in the value field put <cfif isDefined("session.whatever")><cfoutput>#session.whatever#</cfoutput></cfif> > Hi All. I would like to detect that the user has clicked the back > button. I need to do this in order to get the last value entered in > the form. ( currently using session variables to recall the last item > searched for ). However as you can guess, by pressing the back button > you do not get the lastest session items, you get the old ones. > > any work arounds?

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
RADEMAKERS Tanguy
05/03/2005 02:03 PM

There is no way to do this from the server side, as no page request is made (it is loaded from cache), so you will have to use javascript - here's an example from the web: -----start------- <HTML> <BODY ONLOAD="handleBackButton()"> <FORM NAME="backtrack"> <INPUT TYPE="HIDDEN" NAME="isBack" VALUE="No"> </FORM> <SCRIPT LANGUAGE="JAVASCRIPT"> <!--//   var isBackDefault="No";   var isBack;      function handleBackButton(){      isBack = (isBackDefault != document.backtrack.isBack.value);      document.backtrack.isBack.value="Yes";      document.backtrack.isBack.defaultValue="Yes";   }      function isBackButtonUsed(){    return isBack; } --> </SCRIPT> <form>   <input type=button value="how did I get here?" onclick="(isBackButtonUsed())? alert('Back button was used'):alert('Page was loaded normally')"> </form> </BODY> </HTML> -----end------- note that this approach will detect any load from cache - so the forward button as well. Once you've detected that the page was loaded from cache, you can use the javascript location.reload(true) function to force a reload of the page. /t ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

November 27, 2014

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
             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             

Designer, Developer and mobile workflow conference