Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Disable back button/clear history via CF?

Engaged ,
Dec 10, 2010 Dec 10, 2010

Hi Gang-

I've taken over an app and I've been tasked with spot fixes, enhancements, etc. I have a poorly developed sequence of forms that really needs to be re-done, but for now a simple fix would be to eliminate the user's ability to use the browser's back button. It's been years since I've been faced with this concern, but does anyone know how I can clear out a browser window's history, or mitigate the back button functionality? This is an intranet app with very specific usage rules, so this solution will work in this scenario.  cfcontent? cfheader? Anyone?

Thanks in advance,

Rich

3.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 10, 2010 Dec 10, 2010

richardELeach wrote:

cfcontent? cfheader? Anyone?

NOPE, JavaScript.

ColdFusion doens't run in the browser.  It can't do anything in the browser (other then generate browser based code like CSS, HTML, JavaScript, etc).  ColdFusion only executes on the server.

Anything you want done in the browser will need to be done with a browser based technology like JavaScript.

Just be aware of all the limitations of that.  Breaking the backbutton is can always be circumvented and maybe very problematic for users.

Now if we knew why you feel a need to break basic browser functionality, we may be able to offer server side solutions to the problem.  Such as simple coldfusion tricks that prevent the resubmission of forms or expiring reports so that they can not be viewed by going back.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 10, 2010 Dec 10, 2010

... thanks for your input. I fully agree about the problems of limiting the back button and the purpose and place of Javascript and CF. I'm thinking of the cfcontent, cfheader, etc. tags to be able to put some kind of flag in place so that if a user back's up then some sort of synchronization breaks, prompting an alert or pop up of some kind, at least I was hoping.... I can drop that kind of functionality into my controllers upon submission, even redirect a user if needed... see where I'm getting to? It won't be pretty but these are the requirements I'm dealing with.

Thanks again!

Rich

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 10, 2010 Dec 10, 2010
LATEST

Your heading down the right track I think.  But it shouldn't require <cfcontent...>.  Maybe <cfheaders...> though.

Just the use of flags.  This is a common technique to prevent the double submission of a form.  On the page that generates a form.  Set a flag in persistant memory such as session with a unique value (UUID works well).  Then include that unique value in a hidden field on the form.  Then on the form submission page the first time it is received process the form and set the flag for that unique value to expired. If any future requests with that form data are received display your alert or pop up or redirect as desired.

You may also want to had these html head and http header tags to prevent the caching of pages.  Thus EVERY time a user views a page, the browser will request it from the web server.  And ColdFusion can judge whether the content is stale or not and again disply alerts or popups or redirects as desired.

Set a meta tag for content expiration

<meta http-equiv="expires" content="Mon, 06 Jan 1990 00:00:01 GMT"> 

You can also use CFHEADER to send a header to the browser forcing it not to cache the data

<cfheader name="expires" value="#now()#"> 
<cfheader name="pragma" value="no-cache">
<cfheader name="cache-control" value="no-cache, no-store, must-revalidate">

http://www.bpurcell.org/blog/index.cfm?mode=entry&entry=1075

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources