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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Website doesn't show up on history.

    I have done a lot of research into this and what I have found is that it is impossible to use javascript to delete your own history BUT you can use javascript to overwrite your pages history. What I need to know is how I would incorporate this into a button so when you wanted to leave the site you would just click the button and it would take you to somewhere like Google News and change the browsers history to google news.

    Thanks in advance!

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,309
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Why do you want to do that? Sounds as though the site might be something disreputable.

    The browser history is protected and cannot exposed to script for anything other than going back and forward. It would leave people vulnerable to privacy violations.
    Last edited by Philip M; 05-06-2007 at 09:15 AM.

  • #3
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Philip: No, I know it is possible to do with this script:
    location.replace('nextpage.html')

    But what I would do with that script is beyond me.

  • #4
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can't put a url in the history that the user hadn't traveled too. What replace does is allows you to avoid putting your own history in. I believe the way it works is like this.

    Suppose your history was

    www.google.com
    www.yahoo.com

    and the went to your site. Then the user clicks on a button on your site that does

    location.href = "www.msn.com";

    sends them to www.msn.com so the history would look like

    www.google.com
    www.yahoo.com
    www.yoursite.com
    www.msn.com

    But if instead the button did

    location.replace("www.msn.com") then the history would look like

    www.google.com
    www.yahoo.com
    www.msn.com

    So the function replaces your spot in the url history with the one you want to go to. I believe one design theory for using it is when you have a page and all it does is forward you to another page (like after a post message). It can make a more appropriate user history conforming to what the user would expect instead of what actually happened.

    I've never used it myself so it's possible there are more restrictions on its use.

    david_kw

  • #5
    Regular Coder
    Join Date
    Feb 2005
    Posts
    679
    Thanks
    0
    Thanked 16 Times in 15 Posts
    What I need to know is how I would incorporate this into a button...
    Code:
    <form name="jump" id="jump" method="post" action="" enctype="multipart/form-data">
    <input type="button" name=".button" id=".button" value="Google" onclick="location.replace('http://www.google.com/')" />
    </form>
    As David said and you noted, it does replace the current page with the target location in the browser history. There are legitimate reasons when you would not want a 'back button' to access a previous page.


  •  

    Posting Permissions

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