as the title says, "close popup window after submit then redirect to parent".
how do i do that?

i google it and i saw that some people are using the following code:

window.close();
window.opener.location.reload();

The problem is, i dont know how to use and where them.

pls guide me. Ime really a newbie in javascrpt...

p.s.: I use window.open to open the popup window.

Thanks! :)

try this:

<script language="JavaScript" type="text/javascript">
 function CloseAndRefresh() 
  {
     opener.location.reload(true);
     self.close();
  }
</script>
You can call the function a couple of ways. You can use a link:
<a href="#" onClick="CloseAndRefresh(); return:false;">Close</a>

Or a button:
<input type="button" value="close" onClick="CloseAndRefresh();"

Or you can make it part of the submit:
<input type="submit" value="submit" onClick="CloseAndRefresh(); return:true;"

it did solve my problem :) thanks

Please mark solved threads as closed.
Glad I could help.

more and more users do not allow popup windows, the code will fail
better than a popup is a layer in the original page, that can be hidden or displayed at will, with a z-index higher than the rest of the page.
layers in the current page cannot be blocked by popup blockers

layer in this instance refers to an element sized and positioned to overshadow all other items in the page onclick='formname.display:block' for this element shows the contents of the div(example) and hids all other content onsubmit='formname.display:none;' returns to the prior page, no-popups

not code sample, a thought exercise

more and more users do not allow popup windows, the code will fail
better than a popup is a layer in the original page, that can be hidden or displayed at will, with a z-index higher than the rest of the page.
layers in the current page cannot be blocked by popup blockers

layer in this instance refers to an element sized and positioned to overshadow all other items in the page onclick='formname.display:block' for this element shows the contents of the div(example) and hids all other content onsubmit='formname.display:none;' returns to the prior page, no-popups

not code sample, a thought exercise

Hi almostbob!
Thanks for informing me..
Im now thinking to get rig of this popup thing..
Can you help me how to do what you are saying?
Sample codes will help.
Thanks

sample

<script type="text/javascript">
<!--
function hideIt() {
if(document.getElementById) { document.getElementById('layer1').style.visibility='hidden';}
if(document.layers) {document.layers['layer1'].visibility='hide';} }
function showIt() {
if(document.getElementById) {document.getElementById('layer1').style.visibility='visible';}
if(document.layers) {document.layers['layer1'].visibility='show';} }
--></script>
<button style='top:0;' id='openform' onClick="showIt();">fill form</button>
<div id="layer1" style="position:absolute; left:0; top:0; width:100%; visibility:hidden; padding:30%; margin:0; background:#ececec; border: 1px solid;">
Form
<form onsubmit="hideIt();top.location.reload();" action='somefile' method='post'>
something? <input name='somename' type='text'><br>
<input type='submit'><br>
<button id="form" onClick="hideIt();">Close without completing</button>
</form>
</div>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.