PDA

View Full Version : Page reload



kalleballe
Jun 16th, 2002, 03:15 PM
Hello!

I'm looking for a script that can reload a page immidietly when the surfer enters it, but only ONCE.

JohnKrutsch
Jun 16th, 2002, 03:26 PM
You could try something like this but it kind of depends on how you are already using the querystring:

if(document.location.search.substr(1)!="reloaded")location=location.href+"?reloaded"

kalleballe
Jun 16th, 2002, 03:48 PM
thank you! it's working perfect! :thumbsup:

is it possible to get rid of the ?reloaded extension at the url? it's not important, just want to know if it's possible :)

JohnKrutsch
Jun 16th, 2002, 11:57 PM
Not using this method, thats how it knows it has been reloaded once.

glenngv
Jun 17th, 2002, 01:02 AM
there is another way of doing this.

<head>
<script>

if (window.name!="reloaded") doRefresh();

function doRefresh(){
window.name="reloaded";
location.reload();
}
</script>
</head>

if the current window or frame is not a target of any link or form, then you can do the trick with window.name. This property persists even if the page has unloaded.


Originally posted by kalleballe
thank you! it's working perfect! :thumbsup:

is it possible to get rid of the ?reloaded extension at the url? it's not important, just want to know if it's possible :)

JohnKrutsch
Jun 17th, 2002, 01:20 AM
Nice one!


Originally posted by glenngv
there is another way of doing this.

<head>
<script>

if (window.name!="reloaded") doRefresh();

function doRefresh(){
window.name="reloaded";
location.reload();
}
</script>
</head>

if the current window or frame is not a target of any link or form, then you can do the trick with window.name. This property persists even if the page has unloaded.

FJbrian
Jun 17th, 2002, 07:41 PM
why not just use a meta tag to refresh the page?
I have a similar question in the cgi board so....maybe this is my answer:)
Oh no wait that would referesh the page multiple times....

oh well

John you work for theplanet.com?

meems
Jul 21st, 2002, 04:37 PM
I am wondering how to use this reload once script when a back button is pressed? Certain select boxes disappear and have to do a refresh but only once.
Thanks

FJbrian
Jul 21st, 2002, 05:12 PM
not sure ya can
of course you could axe the browser toolbars and add in your own back button to do this

fitchic77
Sep 12th, 2002, 07:23 PM
if(document.location.search.substr(1)!="reloaded")location=location.href+"?reloaded"

I used this above. The problem is that I have to use the browsers BACK button to get back to the original page...this doesn't work for that...

any ideas??

Thanks!!
Andrea :eek:

FJbrian
Sep 13th, 2002, 04:09 AM
boy is this easy and yet I'm drawing a blank
go offline and type in a webpage URL
hold your mouse over the text part that says "Back"
it's history-1 or something like that

sorry, overtired.
use that code

hope this blather helps

fitchic77
Sep 13th, 2002, 12:17 PM
my boss won't let me use a back button...it has to be the browsers button...

I'm stumped:

See it in action at:

http://209.118.243.140/test/golfpac3/index.cfm?reloaded


Thanks,
Andrea

fitchic77
Sep 13th, 2002, 02:56 PM
Got it

location.replace(targetURL);

This doesn't record any history in the browser...so I have a redirect page from the posted page which does this piece of code...works great.

see it if you'd like:
http://209.118.243.140/test/golfpac3/index.cfm


THANKS AGAIN
:p

FJbrian
Sep 14th, 2002, 01:30 AM
hey fitchick,
if you ever start an affiliate program, lemme know
I'd imagine I could "peddle your wares" thru my site

fitchic77
Sep 14th, 2002, 02:01 AM
Give me your email address. Our live address is:

http://www.golfpactravel.com


I'm not sure what you are hinting too, so drop me an email:

[email protected]


Thanks,
Andrea

gameover
Feb 17th, 2005, 03:35 AM
if(document.location.search.substr(1)!="reloaded")location=location.href+"?reloaded"
sorry to ask but I'm a JS newbie here.
Would like to ask what's "document.location.search.substr(1)" ?
Or can you show me the website that explains this ?

glenngv
Feb 17th, 2005, 04:26 AM
The more correct form is window.location rather than document.location, although browsers also support the latter.

Anyway, here's the reference about location.search:

http://www.devguru.com/Technologies/ecmascript/quickref/location_search.html

and substr:

http://www.devguru.com/Technologies/ecmascript/quickref/string.html (scroll down to substr)

gameover
Feb 17th, 2005, 06:03 AM
Ok I got it. Very much appreciated.
Thanks very much for the swift reply.