aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How to disable BACK button of the browser? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to disable BACK button of the browser?" Watch "How to disable BACK button of the browser?" New topic
Author

How to disable BACK button of the browser?

Abhilash Etikala
Ranch Hand

Joined: Nov 08, 2009
Posts: 38

Hi everybody,
In my application i am having a online exam which contains a startpage.php and in that start page whenever a user clicks on the link provided the exam starts..(The exam page consists of two frames top and bottom)Top frame is for displaying time running and bottom frame is for exam questions are displayed).
So ,whenever user starts the exam the exam page is displayed the timer starts and questions are displayed in the bottom frame but when the user clicks BACK button of the browser again the startpage.php is displayed and he can again restart his exam on clicking the link which should not happen.

I TRIED:
first time when user starts the exam by clicking the link in startpage.php i initialized a SESSION variable and again for everytime the user enters startpage.php iam checking the session variable whether it is initialized or not.If it is initialized then it means the exam had already started so iam redirecting to error page if not initialized the exam starts.
What i tried is working if i try to open the startpage.php in another tab of the same browser after once he started the exam but it is not working if i click BACK button...
And correct me if my approach is not correct??
any suggestion ??? Thanks in advance...
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
The back button does pulls the page from the cache and not the server. You need to set no cache headers.

Eric
Abhilash Etikala
Ranch Hand

Joined: Nov 08, 2009
Posts: 38

Hi Eric Thanks for reply..
I tried to clear cache using meta tag:
But still not working Is the above is correct?? and how to clear the cache other than <meta> tag...
Thanks in advance...
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Did you clear your cache before trying?

How are the people getting to the 2nd page?

Eric
Abhilash Etikala
Ranch Hand

Joined: Nov 08, 2009
Posts: 38

ya.. i cleared startpage.php using

header("Cache-Control: no-cache");
header("Pragma: no-cache");

on clicking the link it is redirected to exam page...where the exam starts....
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Did you actually clear YOUR cache. Manually remove the files.

Eric
Abhilash Etikala
Ranch Hand

Joined: Nov 08, 2009
Posts: 38

ya i cleared manually...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to disable BACK button of the browser?