Advanced Search

Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Clearing Browser History using JavaScript

  1. #1
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,626
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default Clearing Browser History using JavaScript

    Hi Folks,

    Is it possible for us to clear/erase the contents of the Client's Browser history?

    Rather only one entry which is associated with my site?

    I want to restrict the user going back to a particular page using the 'Back' button in the browser

    Thanks in Advance

    Code Exploiter

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by codeexploiter
    Is it possible for us to clear/erase the contents of the Client's Browser history?
    No.

    Rather only one entry which is associated with my site?
    Still no.

    I want to restrict the user going back to a particular page using the 'Back' button in the browser
    You can't. Write whatever system it is that you're developing to cope with that eventuality.

    Mike

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    If you use window.location.replace("newpage.htm"), the user agent will be sent to newpage.htm, which will replace the current page in the browser's history. This is generally a bad idea, except for:
    1. Redirect pages that might cause the user to become "stuck";
    2. Splash-type pages that contain no content the user might want to revisit.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    If you use window.location.replace("newpage.htm"), the user agent will be sent to newpage.htm, which will replace the current page in the browser's history.
    Which introduces a scripting dependency. That should mean you provide a non-scripted fallback:

    HTML Code:
    <a href="..." onclick="location.replace(this.href); return false;">...</a>
    However, this still means that some users can use the back button.

    So, as I said, it needs to be accomodated server-side.

    Mike

  5. #5
    Join Date
    Nov 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    A possible solution could be adding this simple script in the beginning of the page you don't want the user to goback to.

    <script language="javascript" >
    history.go(1); /* undo user navigation (ex: IE Back Button) */
    </script>

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    262
    Thanked 690 Times in 678 Posts

    Default

    That wouldn't allow them to see the page ever.

    As for the original question... no, you can't delete/change/etc files that are on the users' computers. Simple as that.

    You could do a cookie/IP/session/etc tracking with server or client side programming, or try what twey suggested.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,626
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Yes actually this issue had resolved long time but I missed to post a message that it is resolved.

    I am really sorry about it.

    regards

  8. #8
    Join Date
    Sep 2006
    Location
    England
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry

    Hello all,

    Firstley, interfering with ANY clients' computers is both unprofessional and insulting to say the least. As a web designer your top priority is to ensure the TOTAL SAFETY of ALL your visitors/guests. What rights do you have to attempt to do such things on anyones computer using a CLIENT SIDE script? Ever heard of trusted sites in your browser?

    I agree with MWINTER in that he points out the problems associated with this sort of behaviour - which can only be described as 'internet hooliganism/vandalism'. Are'nt there enough hackers out there without adding to the list?

    The professional/ethical way to restrict unwelcome visitors is to use a SERVER SIDE IP BANNING script - available in PHP from various sources. That way you can at least restrict access from a particular computer without interference with the clients equipment.

    Internet security is of utmost importance to all of us but safety can be achieved without resorting to underhand methods. Try visiting;

    http://www.astalavista.com/

    and;

    http://www.astalavista.net

    These people are PAID to test internet systems - from communication to internet sites for banks etc. I have been a member for a number of years and find the articles very interesting. A lot can be learned from them.

    I apologise if I sound a bit harsh but so is life and the truth often hurts.

    Regards,
    Ges.

  9. #9
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,626
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Quote Originally Posted by Ges
    What rights do you have to attempt to do such things on anyones computer using a CLIENT SIDE script? Ever heard of trusted sites in your browser?
    As a web developer what right do you have to set a cookie in a clients machine without their permission?

    Though cookies doesn't contain any malicious contents (as far as i knew) still it is wrong to set a cookie in a visitor's machine without their consent.

    I am also sorry if i sound harsh.

    I had already mentioned that I've got the answers already and my issue has already resolved.

  10. #10
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    262
    Thanked 690 Times in 678 Posts

    Default

    The point is valid, though.
    cookies are designed to be used, and the user can block them if s/he desires.

    However, deleting something they would expect control of, the history for example, is bad.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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