Refresh page coding

Discussion in 'Javascript' started by Stubbo of Oz, Jan 12, 2008.

  1. Stubbo of Oz

    Stubbo of Oz Guest

    I want to put a link on my web pages to allow the user to click and
    refresh the page.

    I have seen twqo ways to do this:-

    <a href="javascript:location.reload(true)">
    <a href="javascript:history.go(0)">

    Are they both legitimate?

    Is one better than the other?

    Thanks for any info.

    --
    ----------------
    Stubbo of Sydney
    ----------------
     
    Stubbo of Oz, Jan 12, 2008
    #1
    1. Advertising

  2. Stubbo of Oz

    Doug Gunnoe Guest

    On Jan 11, 6:31 pm, Stubbo of Oz <> wrote:
    > I want to put a link on my web pages to allow the user to click and
    > refresh the page.
    >
    > I have seen twqo ways to do this:-
    >
    > <a href="javascript:location.reload(true)">
    > <a href="javascript:history.go(0)">
    >
    > Are they both legitimate?
    >
    > Is one better than the other?
    >
    > Thanks for any info.
    >
    > --
    > ----------------
    > Stubbo of Sydney
    > ----------------


    you could also try

    window.location.href = window.location.href

    as in

    <input type="button" value="Click here to refresh"
    onclick="window.location.href = window.location.href" />

    I make no promises.
     
    Doug Gunnoe, Jan 12, 2008
    #2
    1. Advertising

  3. Randy Webb wrote:
    > Doug Gunnoe said the following on 1/12/2008 8:28 AM:
    >> On Jan 11, 6:31 pm, Stubbo of Oz <> wrote:
    >>> I want to put a link on my web pages to allow the user to click and
    >>> refresh the page.
    >>>
    >>> I have seen twqo ways to do this:-
    >>>
    >>> <a href="javascript:location.reload(true)">
    >>> <a href="javascript:history.go(0)">

    >
    > Both are junk.
    > [...]
    >> you could also try
    >>
    >> window.location.href = window.location.href

    >
    > ...href + "?" + new Date().getTime()
    >
    > might get you a better reload from the server. Reloading from the cache
    > is a waste of time.


    That is why the `reload' method of Location objects accept `true'
    for its first argument which avoids any of the other dirty hacks.


    PointedEars
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
     
    Thomas 'PointedEars' Lahn, Jan 12, 2008
    #3
  4. Randy Webb wrote:
    > Thomas 'PointedEars' Lahn said the following on 1/12/2008 4:35 PM:
    >> Randy Webb wrote:
    >>> Doug Gunnoe said the following on 1/12/2008 8:28 AM:
    >>>> On Jan 11, 6:31 pm, Stubbo of Oz <> wrote:
    >>>>> I want to put a link on my web pages to allow the user to click and
    >>>>> refresh the page.
    >>>>>
    >>>>> I have seen twqo ways to do this:-
    >>>>>
    >>>>> <a href="javascript:location.reload(true)">
    >>>>> <a href="javascript:history.go(0)">
    >>> Both are junk.
    >>> [...]
    >>>> you could also try
    >>>>
    >>>> window.location.href = window.location.href
    >>> ...href + "?" + new Date().getTime()
    >>>
    >>> might get you a better reload from the server. Reloading from the cache
    >>> is a waste of time.

    >> That is why the `reload' method of Location objects accept `true'
    >> for its first argument which avoids any of the other dirty hacks.

    >
    > And then you have to hope that the browser, for whatever reason, honors
    > it.


    The reason would be that this feature is part of DOM Level 0 which so far
    is "honored" by every scriptable HTML user agent due to backwards
    compatibility. It is available in JavaScript 1.1 to 1.3 (NN 3+), moved
    from there with v1.5 to the Gecko DOM; it is available in the MSHTML DOM
    since at least version 4, incorporated in the Opera DOM, the KHTML DOM,
    and (consequently) Apple WebCore (contains Safari's DOM).

    > I have yet to see a browser that would reload from the cache using a
    > date timestamp querystring.


    That is a nice way of saying that this dirty hack fills up the caches along
    the way with next-to-obsolete data needlessly, thereby rendering them useless.


    PointedEars
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
     
    Thomas 'PointedEars' Lahn, Jan 13, 2008
    #4
  5. On 1/12/2008 7:50 PM, Thomas 'PointedEars' Lahn wrote:
    > Randy Webb wrote:
    >> Thomas 'PointedEars' Lahn said the following on 1/12/2008 4:35 PM:
    >>> Randy Webb wrote:
    >>>> Doug Gunnoe said the following on 1/12/2008 8:28 AM:
    >>>>> On Jan 11, 6:31 pm, Stubbo of Oz <> wrote:
    >>>>>> I want to put a link on my web pages to allow the user to click and
    >>>>>> refresh the page.
    >>>>>>
    >>>>>> I have seen twqo ways to do this:-
    >>>>>>
    >>>>>> <a href="javascript:location.reload(true)">
    >>>>>> <a href="javascript:history.go(0)">
    >>>> Both are junk.
    >>>> [...]
    >>>>> you could also try
    >>>>>
    >>>>> window.location.href = window.location.href
    >>>> ...href + "?" + new Date().getTime()
    >>>>
    >>>> might get you a better reload from the server. Reloading from the cache
    >>>> is a waste of time.
    >>> That is why the `reload' method of Location objects accept `true'
    >>> for its first argument which avoids any of the other dirty hacks.

    >> And then you have to hope that the browser, for whatever reason, honors
    >> it.

    >
    > The reason would be that this feature is part of DOM Level 0 which so far
    > is "honored" by every scriptable HTML user agent due to backwards
    > compatibility. It is available in JavaScript 1.1 to 1.3 (NN 3+), moved
    > from there with v1.5 to the Gecko DOM; it is available in the MSHTML DOM
    > since at least version 4, incorporated in the Opera DOM, the KHTML DOM,
    > and (consequently) Apple WebCore (contains Safari's DOM).
    >


    http://www.w3.org/TR/Window/

    It's defined by the W3C as a long standing 'defacto standard', and is
    defined in the April 2006 draft. DOM level 0 wasn't even a real level,
    according to the W3C:

    DOM Level 0
    The term "DOM Level 0" refers to a mix (not formally specified) of
    HTML document functionalities offered by Netscape Navigator version 3.0
    and Microsoft Internet Explorer version 3.0. In some cases, attributes
    or methods have been included for reasons of backward compatibility with
    "DOM Level 0".

    http://www.w3.org/2007/12/WebApps-Charter/WebApp-Charter-2007-proposed.html

    The February 2007 charter defines one of their goals as defining the
    window object. They finally decided to add it to the DOM
    recommendations. It isn't a standard, it is entirely
    implementation-dependent.

    ~A!


    --
    anthony at my pet programmer dot com
     
    Anthony Levensalor, Jan 13, 2008
    #5
  6. Anthony Levensalor wrote:
    > On 1/12/2008 7:50 PM, Thomas 'PointedEars' Lahn wrote:
    >> Randy Webb wrote:
    >>> Thomas 'PointedEars' Lahn said the following on 1/12/2008 4:35 PM:
    >>>> Randy Webb wrote:
    >>>>> Doug Gunnoe said the following on 1/12/2008 8:28 AM:
    >>>>>> On Jan 11, 6:31 pm, Stubbo of Oz <> wrote:
    >>>>>>> I want to put a link on my web pages to allow the user to click and
    >>>>>>> refresh the page.
    >>>>>>>
    >>>>>>> I have seen twqo ways to do this:-
    >>>>>>>
    >>>>>>> <a href="javascript:location.reload(true)">
    >>>>>>> <a href="javascript:history.go(0)">
    >>>>> Both are junk.
    >>>>> [...]
    >>>>>> you could also try
    >>>>>>
    >>>>>> window.location.href = window.location.href
    >>>>> ...href + "?" + new Date().getTime()
    >>>>>
    >>>>> might get you a better reload from the server. Reloading from the cache
    >>>>> is a waste of time.
    >>>> That is why the `reload' method of Location objects accept `true'
    >>>> for its first argument which avoids any of the other dirty hacks.
    >>> And then you have to hope that the browser, for whatever reason, honors
    >>> it.

    >> The reason would be that this feature is part of DOM Level 0 which so far
    >> is "honored" by every scriptable HTML user agent due to backwards
    >> compatibility. It is available in JavaScript 1.1 to 1.3 (NN 3+), moved
    >> from there with v1.5 to the Gecko DOM; it is available in the MSHTML DOM
    >> since at least version 4, incorporated in the Opera DOM, the KHTML DOM,
    >> and (consequently) Apple WebCore (contains Safari's DOM).

    >
    > http://www.w3.org/TR/Window/
    >
    > It's defined by the W3C as a long standing 'defacto standard',


    It isn't. Especially the word "defacto standard" is not contained in the
    definition; that is your interpretation, however not quite false. The term
    was defined first in the W3C DOM Level 2 HTML Specification, because that
    specification defined features that originated from "DOM Level 0":

    ,-<http://www.w3.org/TR/DOM-Level-2-HTML/glossary.html>
    |
    | DOM Level 0
    | The term "DOM Level 0" refers to a mix (not formally specified) of
    | HTML document functionalities offered by Netscape Navigator version 3.0
    | and Microsoft Internet Explorer version 3.0. In some cases, attributes
    | or methods have been included for reasons of backward compatibility with
    | "DOM Level 0".

    > and is defined in the April 2006 draft.


    Sigh. [psf 10.1]

    | Publication as a Working Draft does not imply endorsement by the W3C
    | Membership. This is a draft document and may be updated, replaced or
    | obsoleted by other documents at any time. It is inappropriate to cite
    | this document as other than work in progress.

    > DOM level 0 wasn't even a real level, according to the W3C:


    You don't say.


    PointedEars
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
     
    Thomas 'PointedEars' Lahn, Jan 13, 2008
    #6
  7. On 1/13/2008 6:51 AM, Thomas 'PointedEars' Lahn wrote:
    > Anthony Levensalor wrote:

    [snip]
    >> http://www.w3.org/TR/Window/
    >>
    >> It's defined by the W3C as a long standing 'defacto standard',

    >
    > It isn't.


    It is in the W3C link I quoted. That's verbatim, not interpretation. And
    all the times you've quoted the W3C drafts as a way to prove your point,
    and now they're unacceptable? I'll remember that for the next time you
    point to a draft and whine.


    [snip]

    >> DOM level 0 wasn't even a real level, according to the W3C:

    >
    > You don't say.
    >


    You suck at wrong. Too bad, because it's a condition I imagine you find
    yourself in nearly perpetually.

    --
    anthony at my pet programmer dot com
     
    Anthony Levensalor, Jan 13, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. brian lanning
    Replies:
    0
    Views:
    617
    brian lanning
    Jul 29, 2003
  2. Per Magnus L?vold
    Replies:
    1
    Views:
    5,193
    John C. Bollinger
    Oct 8, 2004
  3. calmar
    Replies:
    11
    Views:
    938
    calmar
    Feb 21, 2006
  4. Pkenty
    Replies:
    0
    Views:
    421
    Pkenty
    May 28, 2004
  5. Jawahar Rajan
    Replies:
    1
    Views:
    307
    Adrienne
    Oct 1, 2003
Loading...

Share This Page