Web Hosting Talk







View Full Version : refresh parent window on close


mjfroggy
08-14-2009, 03:53 PM
Hello. I am using the greybox script found here
http://orangoo.com/labs/GreyBox

However what I want to do is when the close image link is clicked I want the parent window to automatically refresh. I am hoping someone is familar with this script and can tell me what the code would be and where to put it within this script
Thanks

Steve_Arm
09-09-2009, 01:25 PM
This is inline html, there is nothing to refresh. Which means if you refresh the greybox
will disappear. What exactly do you want to do, update some html on the "parent" window
or the whole page?

Edit:
You will have to search for the close function on the script and do the refresh (window.location.reload()).

methodical
09-22-2009, 02:59 PM
I was recently trying to do this same thing (also using GreyBox by OrangeGoo). I modified the gb_scripts.js file. Right at the top there's a function called GB_CURRENT.hide.

I changed the GB_CURRENT.hide function to this:

GB_CURRENT.hide(cb);
// enable us to have an "after close" event (but don't require it)...
if(typeof GB_afterclose == 'function') {
// use a setTimeout so that it's a completely separate instance...
setTimeout("GB_afterclose();", 100);
}
};

Then, I created a GB_afterclose() function on the target page. If you did the same you could put something like window.location.reload() in the GB_afterclose() function (as suggested by Steve).

On a side note--the "if" statement basically makes it so that if the GB_afterclose function doesn't exist on a page then the user won't get an error.

I hope this helps.

Biggrecian
11-11-2010, 12:18 PM
I can't seem to get it to work:

Im using ASP and its doing some inserting into a database which works fine which is the window opened by greybox then I want it to close the window and reload the parent page (it is a schedule so the pop up added the event so when the window closes I want it to refresh the schedule so it shows as added) so I used:

<body onload="parent.parent.GB_hide()">


I then added on the parent page the code as :

<script type="text/javascript" src="../popups/AJS.js"></script>
<script type="text/javascript" src="../popups/AJS_fx.js"></script>
<script type="text/javascript" src="../popups/gb_scripts.js"></script>
<script language="javascript" type="text/javascript">
<!--
function afterclose() {
window.location.reload()
}

// -->
</script>

methodical
11-12-2010, 10:13 AM
Hey Biggrecian,

A few quick tips:

1) There's no need to add a GB_hide() to the body's onload event. The GB_hide() function is called by GreyBox when it closes the child window.

2) If you used the code that I mentioned in my last post then your function should be named GB_afterclose().

3) If you didn't modify the GB_CURRENT.hide function (in gb_scripts.js) then that's all you need to do (but be sure to rename your afterclose function to GB_afterclose).

If you can't get this working then one alternative would be to have your form add a window.location.reload() to the page after it successfully saves the data.

I hope this helps. :-)

Jeremy

rkaartikeyan
02-28-2011, 04:49 AM
After spending lot of time i get this solution...

Really Thanks a Lot Dude!:agree: