Refresh page coding

S

Stubbo of Oz

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.
 
D

Doug Gunnoe

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.

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.
 
T

Thomas 'PointedEars' Lahn

Randy said:
Doug Gunnoe said the following on 1/12/2008 8:28 AM:
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
 
T

Thomas 'PointedEars' Lahn

Randy said:
Thomas 'PointedEars' Lahn said the following on 1/12/2008 4:35 PM:
Randy said:
Doug Gunnoe said the following on 1/12/2008 8:28 AM:
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
 
A

Anthony Levensalor

Randy said:
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:
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!
 
T

Thomas 'PointedEars' Lahn

Anthony said:
Randy said:
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:
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
 
A

Anthony Levensalor

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]
You don't say.

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top