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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

timer refresh with post/get vars

Status
Not open for further replies.

jay123454

Programmer
Jun 15, 2001
46
US
Hi,

I have a few pages that I would like to be refreshed every 60 seconds. I found some javascript code online to do this, but it doesn't look like it's passing my post or get variables.

Is there a way I can force a refresh every 60 seconds and pass the variables also using javascript?

The pages are php pages, but I believe the best solution is javascript.

Here's the code I found online...

<head>
<SCRIPT type="TEXT/JAVASCRIPT" language="JavaScript">
<!--
var sURL = unescape(window.location.pathname);

function fRefreshMe(){
window.location.replace( sURL );
// or you can use window.location.href = "mypage.html"
}
//-->
</SCRIPT>
</head>
<BODY onLoad=setTimeout("fRefreshMe()",10000)>
<html>
Testing this refresh
</html>
</body>

Thanks!
 
Given you want to pass some variables around... maybe Javascript is the best way. Why not set the details in session variables and then use a meta refresh... that way it'll work for non javascript users aswell!

Check out session variables in the php docs... they are dead easy to use.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Given you want to pass some variables around... maybe Javascript is the best way."

How is this done in javascript?

As far as the meta refresh..I've heard it's not supported by some browsers so I would prefer to use the javascript method.

Please let me know the code for the javascript refresh is anyone knows it...I'm sure it should be very simple, but I'm not too familiar with javascript.

Thanks!
 
As far as the meta refresh..I've heard it's not supported by some browsers so I would prefer to use the javascript method.
Then you heard wrong.

If anything, Javascript is going to be less supported than using a meta tag. You really ought to consider using session variables for this... it's a much more robust way to do it.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
OK... I've been digging deeper and there appears to be only one valid reason (that I found) why you might use javascript over meta-refresh... and that is because search engines may (and you have no way of knowing short of asking each search engine company directly) treat you differently if you use meta-refresh over javascript.

Now this then moves on to another javascript solution... AJAX - check out google for a more in depth look at this technique to refresh web page contents (requires javascript).

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Thanks jeff...these pages that need to be refreshed are in a php application, so being search engine friendly is not a consideration.

There are only a few variables...session variables will work, it's just that I already have the pages programmed with GET & POST vars. There aren't too many on each page though so I guess I could just check if the session variables are set and get the vars from there instead of the GET/POST arrays if they are set.

Thanks
jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top