replace method

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff Grippe

    replace method

    Hello and thanks in advance for the help.

    I have been looking for a way to easily eliminate or disable the "Back"
    button on some of my web pages. I was reading my Javascript for Dummies
    Quick Reference and came upon the replace method. The book says:

    "The replace() method of the location object replaces the current history
    entry with the specified URL."

    "The upshot is that after JavaScript scalls the replace() method, the new
    URL loads, and the user can no longer navigate to the previously loaded URL
    by clicking the back button."

    It seems to me that this could be an elegant way to achieve my objective.
    Can someone tell this novice a little more about how this method is used?

    I am also open to other suggestions for accomplishing the same objective.

    Many thanks,
    Jeff


  • Markus Ernst

    #2
    Re: replace method

    Jeff Grippe wrote:[color=blue]
    > Hello and thanks in advance for the help.
    >
    > I have been looking for a way to easily eliminate or disable the
    > "Back" button on some of my web pages.[/color]

    You can open the page in a new window, it will not have a history.

    Anyway the back button is an important part of the browser user interface.
    Disabling it is actually a bad idea as you try to take control over the
    user's possibilities. I can't imagine a situation where this is really
    needed. Also you will get in trouble with browsers that attempt to protect
    users from such things (popup blockers and things like that).

    So it is better to spend your time for enhancing the usability of your
    website the way that the back button can be normally used.

    --
    Markus


    Comment

    • RobG

      #3
      Re: replace method

      Jeff Grippe wrote:[color=blue]
      > Hello and thanks in advance for the help.
      >
      > I have been looking for a way to easily eliminate or disable the "Back"
      > button on some of my web pages. I was reading my Javascript for Dummies
      > Quick Reference and came upon the replace method. The book says:
      >
      > "The replace() method of the location object replaces the current history
      > entry with the specified URL."
      >
      > "The upshot is that after JavaScript scalls the replace() method, the new
      > URL loads, and the user can no longer navigate to the previously loaded URL
      > by clicking the back button."
      >
      > It seems to me that this could be an elegant way to achieve my objective.
      > Can someone tell this novice a little more about how this method is used?[/color]

      It isn't, because visitors hate it. Anyone with JavaScript disabled
      or not available wont have the URL replaced anyway.

      Why do you want to stop navigation back to the current page?

      <URL:http://www.w3.org/QA/Tips/reback>
      [color=blue]
      >
      > I am also open to other suggestions for accomplishing the same objective.
      >[/color]

      1. Ask your users not to use the back button.

      2. Change your site navigation so that whatever issue makes you want
      to break the back button is avoided.


      --
      Rob

      Comment

      • Jeff Grippe

        #4
        Re: replace method


        "RobG" <rgqld@iinet.ne t.auau> wrote in message
        news:42bac768$0 $27720$5a62ac22 @per-qv1-newsreader-01.iinet.net.au ...
        [color=blue]
        > 1. Ask your users not to use the back button.
        >[/color]

        I have but they sometimes do anyway.
        [color=blue]
        > 2. Change your site navigation so that whatever issue makes you want
        > to break the back button is avoided.
        >[/color]

        My users are entering transactions which are end up in my database. They
        have five or six items to enter. Each entry redirects to the next script
        until they finally get to the last item that they must enter where they have
        a set of Submit/Cancel/Start Over buttons.

        I want them to go through the sequence in the order specified. Each of the
        six steps has the Submit/Cancel/Start Over buttons. If they want to start
        over then I want them to use the Start Over button which takes care of clean
        up that is necessary. The same is true for cancel.

        I need to control the sequence of events because some of the items depend on
        other items. Some need to be checked at submit time. There is some setup
        required before the first item. There are all sorts of reasons why I need to
        control the flow of the information entry.

        Thanks for the help.

        Regards,
        Jeff


        Comment

        • Markus Ernst

          #5
          Re: replace method

          Jeff Grippe wrote:[color=blue]
          >
          > My users are entering transactions which are end up in my database.
          > They have five or six items to enter. Each entry redirects to the
          > next script until they finally get to the last item that they must
          > enter where they have a set of Submit/Cancel/Start Over buttons.[/color]

          Start over is actually annoying if you just want to rethink what you entered
          the page before.

          I suggest to solve the problem in your server side application. I think that
          most or all common server side scripting languages support sessions. Store
          the entered data in a session, then you can change it if the user goes back
          and changes his/her mind. Then at the end of the transaction show a summary
          of all entered data and ask the user to confirm it, then store it in the
          database.

          HTH
          Markus


          Comment

          • Danny

            #6
            Re: replace method



            Nothing to it, location.replac e('YOURURLHERE' ); it loads the new file in
            the browser but it doesn't add it to the window.history object, so,
            there's a Back button, but is greyed out if there's no window.history,
            there might be some history, but the one url that loaded off
            location.replac e(), won't show there. If you are the webserver
            administrator, there are ways to send http-headers to the client to tell
            it not to cache or you can also just use a session if mild-security is the
            issue, no js needed.


            Danny

            On Thu, 23 Jun 2005 07:14:06 -0700, Jeff Grippe <jgrippe@hilldu n.com>
            wrote:
            [color=blue]
            > Hello and thanks in advance for the help.
            >
            > I have been looking for a way to easily eliminate or disable the "Back"
            > button on some of my web pages. I was reading my Javascript for Dummies
            > Quick Reference and came upon the replace method. The book says:
            >
            > "The replace() method of the location object replaces the current history
            > entry with the specified URL."
            >
            > "The upshot is that after JavaScript scalls the replace() method, the new
            > URL loads, and the user can no longer navigate to the previously loaded
            > URL
            > by clicking the back button."
            >
            > It seems to me that this could be an elegant way to achieve my objective.
            > Can someone tell this novice a little more about how this method is used?
            >
            > I am also open to other suggestions for accomplishing the same objective.
            >
            > Many thanks,
            > Jeff
            >
            >[/color]



            --
            Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

            Comment

            • RobG

              #7
              Re: replace method

              Jeff Grippe wrote:[color=blue]
              > "RobG" <rgqld@iinet.ne t.auau> wrote in message
              > news:42bac768$0 $27720$5a62ac22 @per-qv1-newsreader-01.iinet.net.au ...
              >
              >[color=green]
              >> 1. Ask your users not to use the back button.
              >>[/color]
              >
              >
              > I have but they sometimes do anyway.
              >
              >[color=green]
              >> 2. Change your site navigation so that whatever issue makes you want
              >> to break the back button is avoided.
              >>[/color]
              >
              >
              > My users are entering transactions which are end up in my database. They
              > have five or six items to enter. Each entry redirects to the next script
              > until they finally get to the last item that they must enter where they have
              > a set of Submit/Cancel/Start Over buttons.
              >
              > I want them to go through the sequence in the order specified. Each of the
              > six steps has the Submit/Cancel/Start Over buttons. If they want to start
              > over then I want them to use the Start Over button which takes care of clean
              > up that is necessary. The same is true for cancel.
              >
              > I need to control the sequence of events because some of the items depend on
              > other items. Some need to be checked at submit time. There is some setup
              > required before the first item. There are all sorts of reasons why I need to
              > control the flow of the information entry.
              >[/color]

              Perhaps XMLHttpRequest will do the job. As each section is completed,
              send the data back to your server and present the next section based on
              the content delivered from the previous send. The data itself can be
              cached in the page in hidden fields or on your server.

              You could provide an 'in-page' back button that goes back up the
              sections, clearing the hidden elements for each section so users can go
              back to fix previous sections. If you are caching at the server,
              keeping the sessions synchronised will require a bit of thought.

              But for non-JavaScript visitors, you will need to present a navigable
              version that goes to the server for every section - sessions have been
              suggested.



              --
              Rob

              Comment

              • Jeff Grippe

                #8
                Re: replace method


                "RobG" <rgqld@iinet.ne t.auau> wrote in message
                news:vsHue.2284 $Zn.103165@news .optus.net.au.. .[color=blue]
                > Perhaps XMLHttpRequest will do the job. As each section is completed,
                > send the data back to your server and present the next section based on
                > the content delivered from the previous send. The data itself can be
                > cached in the page in hidden fields or on your server.
                >
                > You could provide an 'in-page' back button that goes back up the
                > sections, clearing the hidden elements for each section so users can go
                > back to fix previous sections. If you are caching at the server,
                > keeping the sessions synchronised will require a bit of thought.
                >
                > But for non-JavaScript visitors, you will need to present a navigable
                > version that goes to the server for every section - sessions have been
                > suggested.
                >[/color]

                My scripting language does support sessions. The way I'm considering dealing
                with this at the moment would be to create a session variable that tells me
                where in the process I am. At the top of each session I would put some
                script code with checks that session variable and loads the correct script
                along with a reminder that things must be done in sequence.

                Thanks for the help.

                Jeff


                Comment

                Working...