[thelist] JS Tip

Joshua Olson joshua at alphashop.net
Sun Dec 23 07:48:51 CST 2001


<tip type="JS and Forms" author="Joshua Olson">

If you have a form in a popup window that submits back into the opening
window (aka opener) and closes itself at the same time, use something like
this:

<form method="post"
      action="url"
      target="opener_win_name"
      onsubmit="setTimeout('closeWindow()',100); return true;">
  ...
</form>

<script language="JavaScript" type="text/javascript">
  function closeWindow()
  {
    window.close();
  }
</script>

This solves the issue whereby if you simple execute a window.close() in the
onsubmit trigger the form never actually gets submitted back to the opener.
This problem occurs in more than a few versions of NN, at least.

Note: Make sure the opener has a name defined.  This can be done by
executing this somewhere in the opener:

top.name='opener_win_name'

Of course, replace "opener_win_name" with whatever you feel is appropriate.
:)

</tip>





More information about the thelist mailing list