By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,360 Members | 1,412 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,360 IT Pros & Developers. It's quick & easy.

Disabling back button is not working in firefox

P: 21
Hi all

i am working on a site
in which user need to be in same page
when the user clicks on back button

Its working in IE, Chrome but not in firefox
in firefox when i click on the back button though i have embedded the script
its not working
can anyone please let me know the solution

here i am forwarding the script function for back button functionality
which i have called using body onload


JAVA SCRIPT FUNCTION :-
-----------------------------------------

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. function DisablingBackFunctionality()
  4. {
  5. var URL;
  6. var i ;
  7. var QryStrValue;
  8. URL=window.location.href ;
  9. i=URL.indexOf("?");
  10. QryStrValue=URL.substring(i+1);
  11. if (QryStrValue!='X')
  12. {
  13. window.location=URL + "?X";
  14. }
  15. }
  16.  
  17.  
  18.  

Thanks in advance
waiting for your valuable reply
Nov 5 '08 #1
Share this Question
Share on Google+
7 Replies


acoder
Expert Mod 15k+
P: 16,027
The first question to ask yourself is why you're trying to disable the back button. Rarely is it a good idea. Is it to prevent logged out users from seeing cached content, or to prevent loss of data in a web application, or what?
Nov 5 '08 #2

P: 21
The first question to ask yourself is why you're trying to disable the back button. Rarely is it a good idea. Is it to prevent logged out users from seeing cached content, or to prevent loss of data in a web application, or what?

Actually i dont want to show the users the previous page
after logged out
show i need to disable the back button
could u please guide me towards the solution
Nov 5 '08 #3

acoder
Expert Mod 15k+
P: 16,027
In that case, prevent caching on the previous page, so when someone is logged out and goes back, they see the login page instead of the page they were at.
Nov 5 '08 #4

P: 21
I have tried

with

Expand|Select|Wrap|Line Numbers
  1. window.history.forward(-1);
  2.  
bt its working in firefox fine
but its not working perfectly in Chrome.
Nov 5 '08 #5

acoder
Expert Mod 15k+
P: 16,027
That's a bit of a hack. What if someone has JavaScript disabled?

Disable caching in your server-side script/code.
Nov 5 '08 #6

P: 21
thanks fr ur replies
Nov 5 '08 #7

acoder
Expert Mod 15k+
P: 16,027
You're welcome. So did you get it working?
Nov 5 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.