Refresh page on entry

gavin681's picture

They have: 184 posts

Joined: May 2001

Hi everyone,

Does anyone know how I can get my page to refresh only once when a visitor first visits it?

Right now I'm using:

But I want it just to refresh on entry.

I've got "the word of the day" on my page but it always gets stuck in the cache.

My page: http://www.bahamaswriter.com/

Any help would be much appreciated.

Thanks,
Gavin

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Use JavaScript -- set a variable, and increment the variable when the page loads the second time. test to see if the variable is 0 or 1, if 0 (first load), then reload. If 1, then do nothing.

Smiling Suzanne

gavin681's picture

They have: 184 posts

Joined: May 2001

Tried that but it just kept reloading the page every second.

::Gavin

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

you tried using JavaScript?

If it's reloading every second, you aren't testing for the variable.

Suzanne

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

you can also use PHP, or fix whatever the problem is with the piece that doesn't load.

Netscape has an issue with CSS, so in the Netscape forums (netscape.com -- the developer forums), you can find refresh scripts (javascript) that will reload the page just once to fix the CSS problem.

Suzanne

gavin681's picture

They have: 184 posts

Joined: May 2001

Thanks Suzanne,

I have set it at "60" and seems to be working ok.

::Gavin

They have: 9 posts

Joined: Dec 2001

Quote: Originally posted by Suzanne
Use JavaScript -- set a variable, and increment the variable when the page loads the second time. test to see if the variable is 0 or 1, if 0 (first load), then reload. If 1, then do nothing.

Smiling Suzanne

Where can I find a javascript code that makes the page refresh just once. All the ones I found are to refresh and send to another page.

Thank you for any help you could give me on this
Kimberly

gavin681's picture

They have: 184 posts

Joined: May 2001

>>Where can I find a javascript code that makes the page refresh just once.<<

Yeah. That seem to be the million dollar question.

It must be able to be done.

Gavin

Jack Michaelson's picture

He has: 1,733 posts

Joined: Dec 1999

I found this link:
http://developer.irt.org/script/973.htm

It works only with frames,
tried to get it to work without frames... but did not succeed (yet)

Hope it helps a bit,

Shakespeare: onclick || !(onclick)

gavin681's picture

They have: 184 posts

Joined: May 2001

OK I figured it out here is the code:

Using the complete URL forces the page to reload from the server and not the cache.

This code reloads the page only once!

Gavin

gavin681's picture

They have: 184 posts

Joined: May 2001

I don't know it was working but every time I closed the browser and reopened in it stopped reloading only once.

We will have to keep searching for the right code to do this.

Gavin

gavin681's picture

They have: 184 posts

Joined: May 2001

OK looks like the only way to do this is to make two of the same page (add a mirror page).

Add this code to the original page (replace my url with your mirror page url:

<script LANGUAGE="JavaScript1.1">

</script>

Gavin

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

okay, look, there is a fix for the Netscape onresize error. I'll track it down, because it should work.

However, you really need to look at why you want to refresh the page. It would be far better to prevent caching if the content must be updated frequently, than to force a refresh.

I'll see if I can find it, back later,

Suzanne

gavin681's picture

They have: 184 posts

Joined: May 2001

Will this work?

<script language="Javascript"
src="http://www.dictionary.com/wordoftheday/wotd.js"></script>

.::Gavin

detox's picture

They have: 571 posts

Joined: Feb 2001

This is adapted from a script on IRT, plasce this in the head of you document

<?php
&lt;script language=\"JavaScript\"&gt;<!--
var Passed = '' + location.search;
   
if (Passed != '' && Passed != 'undefined')
    Passed = parseInt(Passed.substring(1));
    
else
    Passed = 1;
    //document.write(\"this page has been refreshed\");


function loopy() {

    loc = window.location.href
    sPos = loc.indexOf('?');
    if (sPos != -1) loc = loc.substring(0,sPos); // loose existing search
    window.location = loc + (Passed-1);


}
//-->&lt;/script&gt;
?>

and place this in your body tag
<?php
onLoad
=\"setTimeout('loopy()',10000)\"
?>

this was meant to be a script to refresh the page 3 times I simply changed the variable Passed to 1

Jack Michaelson's picture

He has: 1,733 posts

Joined: Dec 1999

That's a great script detox!

detox's picture

They have: 571 posts

Joined: Feb 2001

Isn't that always the way, the best scripts are never your own!!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.