Forum Moderators: open

Message Too Old, No Replies

Automatically reloading a page while passing variables

Can you refresh a page after a certain amount of time and pass some vars?

         

sawatkins

7:48 pm on Apr 24, 2008 (gmt 0)

10+ Year Member



Hello all,

Like the title says, I'm wondering the feasibility of reloading a page after a certain amount of time and passing some variables when it reloads. At that point, I'll be using PHP to collect the vars.

Hope all that was clear. Thanks in advance.

httpwebwitch

8:06 pm on Apr 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yes - you can set a timer with setTimeout() [msdn2.microsoft.com], and reload the page with a querystring appended to the URL.

However it sounds to me like you should be looking at an AJAX Pattern [ajaxpatterns.org] instead.

sawatkins

8:15 pm on Apr 24, 2008 (gmt 0)

10+ Year Member



You are SO right about using AJAX for this app. Unfortunately, that's not in the cards at this point, as the program is fully developed, and I don't have the time and resources to rewrite it.

So ... my Javascript is about as poor as I am. Can anyone help me out and throw me a bone on how exactly to use setTimeout() and reload a page with a querystring appended to the URL?

Demaestro

8:37 pm on Apr 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



well to reload the page with Js you would call this

window.location = '/page_name?variable1=hello&variable2=world';

I also think this will work:
self.parent.location = '/page_name?variable1=hello&variable2=world';

All you need is to nest that code into a timer and set it to fire after the timer runs out.

I think like this will work

window.setTimeout("self.parent.location = '/page_name?variable1=hello&variable2=world'", 1000);

[edited by: Demaestro at 8:57 pm (utc) on April 24, 2008]