954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Close popup window after submit then redirect to parent

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! :)

rakwel10
Junior Poster in Training
68 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

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;"
ddymacek
Posting Whiz
317 posts since Jun 2010
Reputation Points: 36
Solved Threads: 64
 

it did solve my problem :) thanks

rakwel10
Junior Poster in Training
68 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

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

ddymacek
Posting Whiz
317 posts since Jun 2010
Reputation Points: 36
Solved Threads: 64
 

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

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

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

rakwel10
Junior Poster in Training
68 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

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'>
<input type='submit'>
<button id="form" onClick="hideIt();">Close without completing</button>
</form>
</div>
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: