Solved

Back button redirect

Posted on 2016-08-25
5
105 Views
Last Modified: 2016-09-09
Is there a way to re-direct if someone hits the back button?  Instead of going back one page I would like to redirect the back button to the homepage.
0
Comment
Question by:rgranlund
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
Sandar Aye earned 500 total points
ID: 41770627
Please change the home page link that you want to redirect if someone hits the back button

 jQuery(document).ready(function($) {

        if (window.history && window.history.pushState) {

            window.history.pushState('forward', null, './#forward');

            $(window).on("popstate", function() {
                window.location.href = "http://www.homepage.com";
            });

        }
    });
0
 
LVL 28

Expert Comment

by:omgang
ID: 41770630
I just went through an exercise investigating this in ColdFusion.  I was able to accomplish what I wanted by using meta tags in the page headers.  Do a Google search on
meta tag no cache

OM Gang



Example from my CF page
<!--- testing http cache control headers -- OMGang 060216 --->
 <cfheader name="expires" value="#now()#">
 <cfheader name="pragma" value="no-cache">
 <cfheader name="cache-control" value="no-cache, no-store, must-revalidate">
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41770692
If you succeed in doing that, I would avoid going to your web site.  You are trying to take control of my browser in ways that are Not acceptable to me.  I don't know what your actual problem is that you're trying to solve but I don't think that's a good way to do it.
0
 
LVL 28

Expert Comment

by:omgang
ID: 41770732
@Dave Baldwin
In my particular circumstance, the goal was to protect user personally identifiable information (PIN) after they had logged out of an application.   The browser back button will reload previously viewed pages that may include PIN and the concern was with users accessing the application from a public browser (kiosk, etc.) and then walking away.  This was a topic of quite some discussion that ultimately concluded with us not implementing the no-cache meta tags but, instead, a displayed message to the user instructing them to close the browser upon logout.  Still, the meta-tag option does provide the functionality the author inquired about.
OM Gang
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41770852
omgang, your problem and solution are not what the original question is about as best I can tell.  There are ways to prevent viewing private info after a logout that do not involve hijacking the Back button.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

630 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