By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,435 Members | 2,939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,435 IT Pros & Developers. It's quick & easy.

Refresh page coding

P: n/a
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
----------------
Jan 12 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Jan 11, 6:31*pm, Stubbo of Oz <stu...@invalid.invalidwrote:
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.
Jan 12 '08 #2

P: n/a
Doug Gunnoe said the following on 1/12/2008 8:28 AM:
On Jan 11, 6:31 pm, Stubbo of Oz <stu...@invalid.invalidwrote:
>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.
>Are they both legitimate?
Are they both legitimate junk? Yes.
>Is one better than the other?
Junk is junk.
>Thanks for any info.

--
----------------
Stubbo of Sydney
----------------

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.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 12 '08 #3

P: n/a
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 <stu...@invalid.invalidwrote:
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. I have yet to see a browser that would reload from the cache using a
date timestamp querystring.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 12 '08 #4

P: n/a
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
Jan 13 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.