Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Clear history / Return to homepage

Clear history / Return to homepage

Scheduled Pinned Locked Moved Web Development
javascripthtmldatabasehelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ASPnoob
    wrote on last edited by
    #1

    Hi All, I'm trying to clear my browsing history then redirect the browser to the homepage when the Home link is clicked by using the following javascript code :

    function Home()
    {
    var Backlen=history.length; history.go(-Backlen);

    window.location.href=index.html;
    }

    The following is how I call the function inside the body of my HTML page

    Home

    Please point out why my javascript code is not working, it does not redirect the browser to the homepage. What I want the code to do when the link "Home" on a page is clicked is clear the browser history, then redirect the browser to the homepage if I am on another page and not on the homepage. Thank you in advance for your help.

    N C 2 Replies Last reply
    0
    • A ASPnoob

      Hi All, I'm trying to clear my browsing history then redirect the browser to the homepage when the Home link is clicked by using the following javascript code :

      function Home()
      {
      var Backlen=history.length; history.go(-Backlen);

      window.location.href=index.html;
      }

      The following is how I call the function inside the body of my HTML page

      Home

      Please point out why my javascript code is not working, it does not redirect the browser to the homepage. What I want the code to do when the link "Home" on a page is clicked is clear the browser history, then redirect the browser to the homepage if I am on another page and not on the homepage. Thank you in advance for your help.

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Why what is not working? The link is not working? The JavaScript is not working? Which part of it? You need to give a little more detail. Edit you post to include this information. Format the code snippet while your at it. Use the "code" toolbar item.


      No comment

      A 1 Reply Last reply
      0
      • N Not Active

        Why what is not working? The link is not working? The JavaScript is not working? Which part of it? You need to give a little more detail. Edit you post to include this information. Format the code snippet while your at it. Use the "code" toolbar item.


        No comment

        A Offline
        A Offline
        ASPnoob
        wrote on last edited by
        #3

        I've edited my questions to make things clearer. Thanks for responding.

        1 Reply Last reply
        0
        • A ASPnoob

          Hi All, I'm trying to clear my browsing history then redirect the browser to the homepage when the Home link is clicked by using the following javascript code :

          function Home()
          {
          var Backlen=history.length; history.go(-Backlen);

          window.location.href=index.html;
          }

          The following is how I call the function inside the body of my HTML page

          Home

          Please point out why my javascript code is not working, it does not redirect the browser to the homepage. What I want the code to do when the link "Home" on a page is clicked is clear the browser history, then redirect the browser to the homepage if I am on another page and not on the homepage. Thank you in advance for your help.

          C Offline
          C Offline
          cjoki
          wrote on last edited by
          #4

          Just looking at your code your issue maybe with the javascript function called Home(), but you call it in the like as home() On a *nix server this may not fly as they are different "H" and "h"; As for clearing the browser history of you visitor, I'm not sure you can (I could be wrong though) but that is something the user can do, not a script. If you want to keep the user from doing a browser refresh and resending post variables, there are methods to do so and they do not invovle the users history.

          Chris J www.redash.org

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups