Did some javascript today in which the parent window creates a popup, and the popup window is used to add info that will show up on the main page each time the info is added. The child window remains on screen until it's closed or the user clicks done.
Some people seem to have problem with this, but the solution I first tried came out working good.
Basically, everytime there is a hidden field called IsPostBack for every form on the page. Everytime the form is submitted, the server side will look for this variable, and if it exists, will add an onLoad handler to the body tag. In ColdFusion, it looks like this:
<body <cfif IsDefined("IsPostBack")>onLoad="javascript:refreshParent();"</cfif>>
The function is as follows:
function refreshParent()
{
window.opener.refreshMe(this);
}
In the parent window, I simply define a refreshMe function to be called by the child popup:
function refreshMe(popupWin)
{
document.location.reload();
popupWin.focus();
}
This will refresh the parent window while keeping the child window in focus. Make sure all form submissions on the parent page use GET method, otherwise on IE you will get a message window asking about POST data resubmission.
Some people seem to have problem with this, but the solution I first tried came out working good.
Basically, everytime there is a hidden field called IsPostBack for every form on the page. Everytime the form is submitted, the server side will look for this variable, and if it exists, will add an onLoad handler to the body tag. In ColdFusion, it looks like this:
<body <cfif IsDefined("IsPostBack")>onLoad="javascript:refreshParent();"</cfif>>
The function is as follows:
function refreshParent()
{
window.opener.refreshMe(this);
}
In the parent window, I simply define a refreshMe function to be called by the child popup:
function refreshMe(popupWin)
{
document.location.reload();
popupWin.focus();
}
This will refresh the parent window while keeping the child window in focus. Make sure all form submissions on the parent page use GET method, otherwise on IE you will get a message window asking about POST data resubmission.

0 Comments:
Post a Comment
<< Home