How to update the current web page? (delete current web page + rewrite the page)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laryten@yahoo.com

    How to update the current web page? (delete current web page + rewrite the page)

    Hi,

    Is there a way to update the same web page instead of getting a new
    page each time we click the submit button? The simplest thing to do is
    to delete the current page (or go back to the previous page) and then
    redraw the page. There are a few possible solutions:

    1. Use the same URL again. But a new page will still be created.

    2. Use the "onsubmit" option:

    <form ACTION="testnet .pl" method="post"
    ONSUBMIT="javas cript:history.g o(-1); return false;">
    .... <input..>

    but the browser goes back to the previous page yet does not
    continue to the ACTION part to draw the same page with new data.

    3. Leave the page alone and use a customized javascript to update the
    input fields of the current page:

    <script language="javas cript" >
    function UPDATE(obj) {
    frm1.txt1.value = Date().toLocale String();
    }
    ....
    <form name="frm1">
    <input name="foo" ONCLICK="UPDATE (this)" type="button">

    4. Someone mentioned that one can post the form to itself. But he/she
    did not explained the details.

    By using javascript this way, the program still works as usual even if
    javascript is turned off. Has anyone done this before?

  • Michael Winter

    #2
    Re: How to update the current web page? (delete current web page+ rewrite the page)

    laryten@yahoo.c om wrote:
    Is there a way to update the same web page instead of getting a new
    page each time we click the submit button?
    Would you care to clarify what you mean? I presume that you want the
    form to remain. Do you want the values to be cleared, too?
    The simplest thing to do is to delete the current page (or go back to
    the previous page) and then redraw the page.
    The simplest thing to do is re-serve the document. You haven't suggested
    why that's not possible.

    [snip]
    <form ACTION="testnet .pl" method="post"
    ONSUBMIT="javas cript:history.g o(-1); return false;">
    .... <input..>
    >
    but the browser goes back to the previous page yet does not
    continue to the ACTION part to draw the same page with new data.
    Of course, because you're cancelling the submission.
    3. Leave the page alone and use a customized javascript to update the
    input fields of the current page:
    [snip]

    And when scripting is disabled?
    4. Someone mentioned that one can post the form to itself. But he/she
    did not explained the details.
    The same as option 1: submit the form to the same URL, and determine
    server-side whether a request is a form submission, or not.

    [snip]

    Mike

    Comment

    • kasnem@yahoo.com

      #3
      Re: How to update the current web page? (delete current web page + rewrite the page)

      Michael Winter wrote:
      laryten@yahoo.c om wrote:
      >
      Is there a way to update the same web page instead of getting a new
      page each time we click the submit button?
      >
      Would you care to clarify what you mean? I presume that you want the
      form to remain. Do you want the values to be cleared, too?
      I have many "Load' submit buttons on the page, one for each file to
      be uploaded. So When user clicks one of these 'Load' button, I wish I
      can upload the chosen file and refresh the screen with the same
      form/page. This way if they upload 10 files and click "Back" button of
      the browser, they will go back to the previous page, not the 9 pages
      that the browser normally created during the process. (I also have a
      "Load All" button to load all files all in once.)
      The simplest thing to do is to delete the current page (or go back to
      the previous page) and then redraw the page.
      >
      The simplest thing to do is re-serve the document. You haven't suggested
      why that's not possible.
      How to re-serve the document without getting a new page? I thought
      the browser always create a new page for the history record that I am
      trying to avoid.
      [snip]
      >
      <form ACTION="testnet .pl" method="post"
      ONSUBMIT="javas cript:history.g o(-1); return false;">
      .... <input..>

      but the browser goes back to the previous page yet does not
      continue to the ACTION part to draw the same page with new data.
      >
      Of course, because you're cancelling the submission.
      It is merely there to indicate that the browser can only do either
      "onclick=histor y.go(-1)" or "action" in this case. If it executes the
      "onclick=histor y.go(-1)" to go back to the previous page, it is already
      on different page/form thus it won't be able to submit anything. This
      is why as far as I know no one has used the "history.go (-1)" and submit
      (action) as well. The browser just go back to the previous page and
      never submit any data to the server so that it can draw a new page.
      3. Leave the page alone and use a customized javascript to update the
      input fields of the current page:
      >
      [snip]
      >
      And when scripting is disabled?
      Those user who has javascript disabled will see the whole history
      stack as usual. Those has javascript enabled will see just one page
      that gets updated.
      4. Someone mentioned that one can post the form to itself. But he/she
      did not explained the details.
      >
      The same as option 1: submit the form to the same URL, and determine
      server-side whether a request is a form submission, or not.
      Whenever I submit a form to the same URL I get a new page unless
      there is a way that the server can ask the browser (client) to go to
      the previous page first.

      I tried to do this by running the javascript:hist ory.go(-1) in the
      body. This is the fifth and sixth alternative:

      5. Execute javascript when the server sends the form:

      <html><body>
      <script language="JavaS cript">
      javascript:hist ory.go(-1); // ask the browser to go back
      </script>
      </body></html>

      <html>body>
      <form.... // then draw a new form
      <input....>
      </body></html>

      When I ran it the browser refreshed the screen and went to the
      current page again. So it didn't work. I also tried putting the
      history.go(-1) inside the second <htmland got same result.

      6. Ask the browser to delete the current page first before drawing new
      page:

      I couldn't find anything on the internet to suggest how to do this.
      [snip]
      >
      Mike

      Comment

      • kasnem@yahoo.com

        #4
        Re: How to update the current web page? (delete current web page + rewrite the page)

        kas...@yahoo.co m wrote:
        Michael Winter wrote:
        3. Leave the page alone and use a customized javascript to update the
        input fields of the current page:
        [snip]

        And when scripting is disabled?
        >
        Those user who has javascript disabled will see the whole history
        stack as usual. Those has javascript enabled will see just one page
        that gets updated.
        Actually you are right, the alternative 3 won't work if the
        javascript is disabled.

        Comment

        Working...