Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript refresh code

Status
Not open for further replies.

monstermash

Technical User
Aug 15, 2000
18
0
0
US
hello,

can anyone tell me if there is a javascript code that will automatically refresh a page (just once) when the page first loads into a browser? i'm only concerned with ie4 and netsacpe4 and above. thanks in advance.
 
onLoad=\"timeID=setTimeout('window.location.reload(false)',60000)..here60000 is time ...but the page is reload
every time u enter a page
 
well this works pretty well but...it reloads the page every 60 seconds. not what i want. is there a way to make it reload the page ONLY when it is first loaded and then to not reload the page after that? ( i would also like this function to load the most current page that is available and NOT to reference the page if it happens to be cached in the users browser.) thanks...
 
You need to use these tags to force it from the cache... I don't claim to know which work and in which circumstances, I grabbed these from some dev site and they seem to work for me:

<META http-equiv=&quot;Pragma&quot; content=&quot;no-cache&quot;>
<META http-equiv=&quot;Cache-Control&quot; content=&quot;no-cache&quot;>
<META HTTP-EQUIV=&quot;Expires&quot; CONTENT=&quot;Mon, 06 Jan 1990 00:00:01 GMT&quot;>

Now, to make reload only once per session, you could reload the page after x amount of seconds using that setTimeout function manu_mr showed you. The trick is to reload the page like this:

window.location=window.location.href+&quot;?fut&quot;

that string at the end can be anything you like...
each time the page loads you check window.location.search property. this will return &quot;?fut&quot; or an empty string ( as long as you are not using QueryStrings for anything else on your app/site) if the location.search.indexOf('fut')<0, you know to reload the page in 60 seconds... otherwise you never make this happen
jared@aauser.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top