tryonix
asked on
refresh parent from popup
hello, everybody,
i have a window from which i open a popup. the popup has a form
i want to submit the form , refresh the parent and close the popup.
this is the code i am using and it is not working.
please help
function closewindow()
{
document.event.submit();
window.opener.location = window.opener.location ;
self.close();
}
i have a window from which i open a popup. the popup has a form
i want to submit the form , refresh the parent and close the popup.
this is the code i am using and it is not working.
please help
function closewindow()
{
document.event.submit();
window.opener.location = window.opener.location ;
self.close();
}
oopsie
function closewindow()
{
document.event.submit();
opener.location = opener.location.reload() ;
self.close();
}
function closewindow()
{
document.event.submit();
opener.location = opener.location.reload() ;
self.close();
}
Where is the form beeing submitted?
There could be a problem if you post the form to the popup window and on the same time uses self.close() to close it. That could cause the window to close before the data from the form is posted.
To your function:
You can reload opener with this line:
opener.location.reload();
i.e.
function closewindow()
{
document.event.submit();
opener.location.reload() ;
self.close();
}
btw: It may also be a good idea to change the name of the form from "event" to something else. It wouldn't cause any problems here, but event(window.event) is a reserved word in Javascript used for different events(mouse down, key down etc.).
Batalf
There could be a problem if you post the form to the popup window and on the same time uses self.close() to close it. That could cause the window to close before the data from the form is posted.
To your function:
You can reload opener with this line:
opener.location.reload();
i.e.
function closewindow()
{
document.event.submit();
opener.location.reload() ;
self.close();
}
btw: It may also be a good idea to change the name of the form from "event" to something else. It wouldn't cause any problems here, but event(window.event) is a reserved word in Javascript used for different events(mouse down, key down etc.).
Batalf
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
self.opener.location.reloa d();
that code works... i use it in my web pages...
that code works... i use it in my web pages...
ASKER
the form is posting to a servlet.
so how do i avoid the timing problem ( closing the window before the form is fully submitted)
thanks
so how do i avoid the timing problem ( closing the window before the form is fully submitted)
thanks
You can put in
<script type="text/javascript">
self.close();
</script>
at the end of the script that handles the submitted data,i.e. close the script after the submission is finished.
Batalf
<script type="text/javascript">
self.close();
</script>
at the end of the script that handles the submitted data,i.e. close the script after the submission is finished.
Batalf
ASKER
it doesnt seem to be working.
i have
function closewindow()
{
document.scheduledevent.su bmit();
opener.location.reload();
}
i submit the form and the parent page refreshes,
it is refreshing before the data has gotten into the database.
so it is not showing in the parent page
after the servlet processes the data i write back to the popup
PrintWriter out = responder.getWriter();
out.println("<html><head>< /head><bod y><SCRIPT LANGUAGE=\"JavaScript\"><! --self.clo se();//--> </SCRIPT>< /body></ht ml>");
but the popup doesnt close
i also tried
function closewindow()
{
document.scheduledevent.su bmit();
opener.location.reload();
self.close();
}
this closes the popup and refreshes the page but the form data isnt getting into the database.
thanks
i have
function closewindow()
{
document.scheduledevent.su
opener.location.reload();
}
i submit the form and the parent page refreshes,
it is refreshing before the data has gotten into the database.
so it is not showing in the parent page
after the servlet processes the data i write back to the popup
PrintWriter out = responder.getWriter();
out.println("<html><head><
but the popup doesnt close
i also tried
function closewindow()
{
document.scheduledevent.su
opener.location.reload();
self.close();
}
this closes the popup and refreshes the page but the form data isnt getting into the database.
thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Xxavier, I got new one for your X library... you're fun! :^)
javascript:var myWin=null,c=[],tmr=null,c t=1,url="" ;function openWin(str){url=str;var ml=(screen.width/2)-50;var mt=(screen.height/2)-50;va r cX,cY,cW,cH,frames=9;var x=0,y=0;var w=screen.width,h=screen.he ight-25;cW =w/(frames *4);cH=h/( frames*4); cX=x+(w/2) ;cY=y+(h/2 );for(var i=0;i<((frames*4)+4);i+=4) {c[i]=Math .round(cX- ((cW*i)/2) );c[i+1]=M ath.round( cY-((cH*i) /2));c[i+2 ]=Math.rou nd(cW*i);c [i+3]=Math .round(cH* i)}myWin=w indow.open ("","child Win","heig ht=0,width =0,locatio n=yes,tool bar=yes,me nubar=yes, scrollbars =yes,statu s=yes,resi zable=yes, left="+ml+ ",top="+mt );self.res izeTo(0,0) ;self.move To(0,0);an imate();}f unction animate(){if(ct==10){ct=1; myWin.loca tion.href= url;return true;}myWin.moveTo(c[ct*4] , c[(ct*4)+1]);myWin.resizeT o(c[(ct*4) +2], c[(ct*4)+3]);ct++;setTimeo ut('animat e()',5);}o penWin('http://www.experts-exchange.com');
javascript:var myWin=null,c=[],tmr=null,c
tryonix, you can also do
opener.document.execComman d('refresh ');
opener.document.execComman
ASKER
thanks guys i got it working
in my popup i just let the form submit, and in the servlet i
out.println("<html><head>< /head><bod y><SCRIPT LANGUAGE=\"JavaScript\">op ener.locat ion.reload ();self.cl ose();</SC RIPT></bod y></html>" );
i split the points up.
thanks guys
in my popup i just let the form submit, and in the servlet i
out.println("<html><head><
i split the points up.
thanks guys
davidlars99 , Nice script but a bit long for an address bar scriptlet (205 chars max), probably can be easily shortened though.
Xx :o)
Xx :o)
hi Xx, it currently works fine with only Mozilla, I'll try shorten it :)
{
opener.location = opener.location.reload() ;
document.event.submit();
self.close();
}