[vox-tech] [OT] JavaScript / HTML Help: Popup windows and forms

Rod Roark rod at sunsetsystems.com
Sat Sep 11 10:57:13 PDT 2004


On Saturday 11 September 2004 02:04 am, Mark K. Kim wrote:
> You can use Javascript to open up a popup window from the main window.
> The popup window can close itself with Javascript (using the "onSubmit="
> attribute I think).  Those are simple enough.

Closing the window in an onsubmit() handler seems untidy.
For example this precludes the script which receives the
form from returning an error message.

What I do is have the server-side script write a block of
JavaScript which in turn closes the window.  Here's a PHP
snippet that may offer some ideas:

<script LANGUAGE="JavaScript">
<?php
  if ($errmsg) {
    echo "window.alert('$errmsg')\n";
    echo "window.back()\n"; // redisplay the form
  } else {
    echo "opener.document.forms[0].submit()\n";
    echo "window.close()\n";
  }
?>
</script>

-- Rod


More information about the vox-tech mailing list