Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2005
    Location
    Paraguay
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Prevent a user going back

    Hi All;

    Please can anybody tell me how I can do the following:
    - Prevent a user press the button 'back' in the browser in order he can't see the previous page or pages anymore.

    - or at least, close the current window and open a new window without history when a user press a link...

    Thanks...

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Location
    London E4 UK
    Posts
    320
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,465
    Thanks
    0
    Thanked 633 Times in 623 Posts
    You can't prevent a person using their back button to go back to the prior page. You can stop pages being loaded into history by loading the replacement page using a Javascript location.href.replace() call.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by vsalinas
    Please can anybody tell me how I can do the following:
    - Prevent a user press the button 'back' in the browser in order he can't see the previous page or pages anymore.

    - or at least, close the current window and open a new window without history
    How not to win return visitors.
    Why would you even want to fukup the visitor's browsing session like that?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •