Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Reload previous page on "back" button.

Posted on 2007-10-03
Medium Priority
Last Modified: 2013-11-19
Hello JS gurus.

Do you know if there's any way, using JavaScript, to ensure that when the back button is pressed, the previous page (history.go(-1)) is *reloaded* for *all users*, rather than just loaded from the cache?

I thought it might be possible to put JavaScript into the page that would reload it if it was reached by pressing the back button, but I have no idea how to detect if this is the case.

Any help would be most appreciated.

Question by:ratWonder
  • 2
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20006156
You should fix your application so it can handle a back or not depend on handling a back

You can expire the page and use POST for one

Author Comment

ID: 20006290
Sorry I didn't understand that.

I tried preventing the browser from caching by adding:
  <meta http-equiv="Pragma" content="no-cache" />
  <meta http-equiv="Expires" content="-1" />

But no joy - when I click back it still shows the old version of the page.
LVL 75

Accepted Solution

Michel Plungjan earned 2000 total points
ID: 20007193
1. you cannot safely detect a back button
2. In page1 you can reload if a cookie is set from page2 (and delete the  cookie), and set a cookie on page2
3. if you have a form and you change the method to POST the page will complain if you use the back button
4. you can remove the page completely from the history by
<a href="page2.html" onClick="location.replace(this.href); return false">Go to page 2 and never return to page1</a>

Expert Comment

ID: 20432400
Forced accept.

EE Admin

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question