Forum Moderators: coopster

Message Too Old, No Replies

Reloading the main page from a button on the popup window

         

eatspinach

10:02 am on Jul 6, 2009 (gmt 0)

10+ Year Member



Hi

i am not even sure if this is possible, here is my problem, i have a popup window where the user selects a number of questions

(kinna like facebook where you add people as friends from the popup window)

so when the user hits the button next to the question that question id is written to the cookie, when the user hits done the window closes and you are back at the main page, the problem is i have to hit refresh to get the values from the cookie...

is their anyway i could force this refresh?

thanks
dave

yaaarr

omoutop

10:10 am on Jul 6, 2009 (gmt 0)

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



well, one way is through javascript

3 steps:
---------------

A) in head of page put this:
<script language="javascript">
function close_and_reload_parent()
{
opener.location.href='file_to_refresh.htm';
self.close();
}
</script>

B) Modify your <body> tag to look something like this: <body <? if ($SelfClose=="ok"){?>onload="close_and_reload_parent()"<? }?>>

C) Modify your scipt in a way that when time comes for close and refresh, a variable like $SelfClose will get the value of "ok" ($SelfClose="ok"; for example). This better happens above the <head> of your page.

So, in the end (when page loads for the final time) you will have something like:

- $SelfClose = "ok";
- Javascript in head section of page
- <body onload="close_and_reload_parent()"> (since the if... statement is set to true/valid)

Hope this helps

eatspinach

11:10 am on Jul 6, 2009 (gmt 0)

10+ Year Member



ah yes i see, this is all very good.. thanks

one small part i cant get my head around, how do i pass the variable from the popup window to the mainpage?

omoutop

11:33 am on Jul 6, 2009 (gmt 0)

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



thats easy..

<script language="javascript">
function close_and_reload_parent()
{
opener.location.href='file_to_refresh.php?var=<? echo $var;?>';
self.close();
}
</script>

where var=... your variable (of course you can have as many of them as you want var=<? echo $var;?>&var1=<? echo $var1?>&...

eatspinach

11:39 am on Jul 6, 2009 (gmt 0)

10+ Year Member



actually i just figured it out, and its working like a machine that works very well, like a Japanese car ha-ha thanks a million i owe you a fanta