Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Go to login page if trying to reach old pages

Posted on 2013-11-07
5
Medium Priority
?
185 Views
Last Modified: 2013-11-25
What do I need to do if I want the browser to go to the login page if I for instance try to reach  old url:s from the history?

I use html and javascript on jboss.
0
Comment
Question by:mdoland
[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
5 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 39630158
from Web Browsing History ???
I am not sure if that can be done

if it was a cookie from within your page you could do a simple javascript if statement  to redirect to the url.. from a logical standpoint I cannot think of a way to do it form your browser history.
 
OR are you talking about hitting the back button in the broswer and going back to previous page ?
0
 

Author Comment

by:mdoland
ID: 39630164
Yes, hitting the back button is a good example.
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 39630222
unfortunately you cannot detect if a user hits the back button :(

only think i can really think of to try is a  javascript function in the body of your HTML


function redirect(){
  window.location = "www.google.com";
}

<!--before your </body> tag -->
<body onload="redirect()">
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 39630503
You cannot prevent the user from accessing the historical pages; nor should you attempt such a hack.  All you will do is make the page less acccessible and any user with an ounce of sense will avoid the page in the future as it should be regarded as a potentially dangerous page.

You are trying to override user controls and fortunately modern browsers are not going to let you do it.

In some browsers you can put up a message using a beforeunload event, but you cannot force the user to go to a home page or anywhere else.

Cd&
0
 
LVL 10

Accepted Solution

by:
GeoffSutton earned 2000 total points
ID: 39632581
//set the cookie with date or other session variable when page loads

document.cookie.last_used=new Date()
....

//check the cookie to see if the session is expired, and if so redirect to login page
if((new Date(document.cookie.last_used).day!=(new Date()).day){
  location.href="login.html"
}

I would not recommend using this in this fashion.  Rather, I would update the cookie on every page load and set the timeout to 5 minutes.  That way, if the user leaves the page for longer than 5 minutes they will be redirected to the home page.  You may need to play with the times, and also you may want to update the cookie on mousemove rather than page load, otherwise you will be redirected if the user browses the page for more than 5 minutes.

Info on setting cookies here:
http://www.w3schools.com/js/js_cookies.asp
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
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…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
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…

598 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