Forums

This topic is locked

Refresh Page

Posted 23 Mar 2007 15:55:38
1
has voted
23 Mar 2007 15:55:38 zafarana gisondi posted:
Hello Everyone! I was just wondering if anyone has any ideas on how to refersh a web page onload. I need to use javascript to accomplish this. I've read millions of posts but nothing seems to be working for me. I've tried adding the meta tag at the top, also tried creating an additional head that goes right after the body, tried <body onLoad="MyReload()"> type things but this always leads to an infinite loop!!! I do'nt want it to refresh every x seconds but rather whenever someone goes on to the page it's always the freshest version of it. Could someone help? Thanks

Replies

Replied 24 Mar 2007 19:09:59
24 Mar 2007 19:09:59 Alan C replied:
HI,

Unless I am mistaken your viewers should always get the latest version unless they have visitied recently and they still have a version of the page cached in their browser. You might be able to force things along by adding some code that tells the browser not to cache the page - not really my area but I know I have problems sometimes when testing because the browser still has a previous version so I do not see my changes.
Replied 27 Mar 2007 18:16:23
27 Mar 2007 18:16:23 zafarana gisondi replied:
Hi! No unfortunately this isn't the case. I don't want it to keep refreshing at x seconds or anything. Just once when you go to the page it should. I tried putting meta tags etc expiring the page but it is still stored in the cache. I just wanted to refrain from having to put a refresh button on the page but that's the only thing that's working now.
Replied 28 Mar 2007 16:56:41
28 Mar 2007 16:56:41 logic1952 slaughter replied:
Here is a way around the loop. It is a bit of a hack:

function refresh(token)
{

window.location.reload();

}
function timer()
{
var token = setTimeout("refresh()", 86400000);
}


then <body onload="timer()";>

the trick is to set the timeout to an extremely large number. If I have done the math correctly, the page will reload 24hrs it has been opened.
Replied 28 Mar 2007 17:01:09
28 Mar 2007 17:01:09 logic1952 slaughter replied:
Actually, I just realized that's not going to work. The trouble being to get the page to reload the first time.

Replied 28 Mar 2007 19:40:12
28 Mar 2007 19:40:12 zafarana gisondi replied:
Yes this is correct. I don't need it to load after a certain time, just once on load. For the time being I just have an 'update me' button that refreshes.

Reply to this topic