0

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

3
Contributors
6
Replies
38
Views
5 Years
Discussion Span
Last Post by almostbob
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;"
0

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

Edited by almostbob: n/a

0

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

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'><br>
<input type='submit'><br>
<button id="form" onClick="hideIt();">Close without completing</button>
</form>
</div>

Edited by almostbob: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.