Implement refresh button

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrus Moor

    Implement refresh button

    I want to add a refresh button to my web page which works like browser
    refresh button:
    it must re-load current page from server.

    How to implement this in javascript ?


  • kaeli

    #2
    Re: Implement refresh button

    In article <3f12b073_1@new s.estpak.ee>, nospam_eetasoft _@online.ee
    shared the illuminating thought...[color=blue]
    > I want to add a refresh button to my web page which works like browser
    > refresh button:
    > it must re-load current page from server.
    >
    > How to implement this in javascript ?
    >
    >
    >[/color]

    <input type="button" name="btn1" onClick="docume nt.location.rel oad
    (true)" value="Reload">


    --
    ----------------------------------------
    ~kaeli~
    There is no justification or rationalization
    for mutilation. Ban declawing as inhumane.


    ----------------------------------------

    Comment

    • Grant Wagner

      #3
      Re: Implement refresh button

      Andrus Moor wrote:
      [color=blue]
      > I want to add a refresh button to my web page which works like browser
      > refresh button:
      > it must re-load current page from server.
      >
      > How to implement this in javascript ?[/color]

      <a href="urlOfCurr entPage.html"
      onclick="window .location.reloa d(true);return false;">Refresh </a>

      or

      <a href="urlOfCurr entPage.html"
      onclick="window .location.href = 'urlOfCurrentPa ge.html?t=' + (new
      Date()).getTime ();return false;">Refresh </a>

      --
      | Grant Wagner <gwagner@agrico reunited.com>

      * Client-side Javascript and Netscape 4 DOM Reference available at:
      *


      * Internet Explorer DOM Reference available at:
      *
      Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


      * Netscape 6/7 DOM Reference available at:
      * http://www.mozilla.org/docs/dom/domref/
      * Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
      * http://www.mozilla.org/docs/web-deve...upgrade_2.html


      Comment

      • Evertjan.

        #4
        Re: Implement refresh button

        Grant Wagner wrote on 14 jul 2003 in comp.lang.javas cript:
        [color=blue]
        > <a href="urlOfCurr entPage.html"
        > onclick="window .location.reloa d(true);return false;">Refresh </a>
        >[/color]

        Why this return false ??

        The page is no longer active !!!

        why the true ?

        This is enough, I think:

        <a href="urlOfCurr entPage.html"
        onclick="locati on.reload();">
        Refresh
        </a>


        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        • Evertjan.

          #5
          Re: Implement refresh button

          Evertjan. wrote on 14 jul 2003 in comp.lang.javas cript:
          [color=blue]
          > Grant Wagner wrote on 14 jul 2003 in comp.lang.javas cript:
          >[color=green]
          >> <a href="urlOfCurr entPage.html"
          >> onclick="window .location.reloa d(true);return false;">Refresh </a>
          >>[/color]
          >
          > Why this return false ??
          >
          > The page is no longer active !!!
          >
          > why the true ?
          >
          > This is enough, I think:
          >
          > <a href="urlOfCurr entPage.html"
          > onclick="locati on.reload();">
          > Refresh
          > </a>[/color]

          The second question I can answer myself:


          location.reload (boolean):
          false [Default]: Reloads the page from the browser cache.
          true: Reloads the page from the server.

          But I never saw any proof of that, does it work ????

          --
          Evertjan.
          The Netherlands.
          (Please change the x'es to dots in my emailaddress)

          Comment

          • Grant Wagner

            #6
            Re: Implement refresh button

            "Evertjan." wrote:
            [color=blue]
            > Evertjan. wrote on 14 jul 2003 in comp.lang.javas cript:
            >[color=green]
            > > Grant Wagner wrote on 14 jul 2003 in comp.lang.javas cript:
            > >[color=darkred]
            > >> <a href="urlOfCurr entPage.html"
            > >> onclick="window .location.reloa d(true);return false;">Refresh </a>
            > >>[/color]
            > >
            > > Why this return false ??
            > >
            > > The page is no longer active !!!
            > >
            > > why the true ?
            > >
            > > This is enough, I think:
            > >
            > > <a href="urlOfCurr entPage.html"
            > > onclick="locati on.reload();">
            > > Refresh
            > > </a>[/color]
            >
            > The second question I can answer myself:
            >
            > location.reload (boolean):
            > false [Default]: Reloads the page from the browser cache.
            > true: Reloads the page from the server.
            >
            > But I never saw any proof of that, does it work ????[/color]

            I'm not sure if window.location .reload(true) guarantees a fresh copy
            from the server or not, which is why I also provided a unique URL
            solution as well.

            As for not returning false from the onclick. While you're right that in
            most cases, it is not necessary, at least one browser (IE 5.5) navigates
            (or begins to navigate to) the HREF immediately after returning from the
            onclick event. As a result, the navigation to the HREF tends to cancel
            any redirection you do in the onclick event. For example:

            <a href="#" onclick="docume nt.forms[0].submit();">Sub mit</a>

            works in almost every browser except IE 5.5, which never submits the
            form.

            For this reason, I always return false to the onclick event (where
            applicable), even when in most cases, it will never be executed.

            --
            | Grant Wagner <gwagner@agrico reunited.com>

            * Client-side Javascript and Netscape 4 DOM Reference available at:
            *


            * Internet Explorer DOM Reference available at:
            *
            Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


            * Netscape 6/7 DOM Reference available at:
            * http://www.mozilla.org/docs/dom/domref/
            * Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
            * http://www.mozilla.org/docs/web-deve...upgrade_2.html


            Comment

            • istalcup@hotmail.com

              #7
              Re: Implement refresh button

              hi,
              I used this code

              <input type="button" name="btn1" onClick="docume nt.location.rel oad
              (true)" value="Reload">

              but it only works once! After I hit it once, all subsuqunet hits just
              keep showing old data. Does it anyone what is wrong?

              Comment

              Working...