How to submit a form in a child HTML window, then call the Javascript function in the parent window, and then close the child window

All,

This should be a pretty simple question, but I haven't found the answer I'm still looking for.

I have a parent HTML window. When the user clicks a button in this window, he opens a child window (for example, "childA.asp")

This child window contains a form. Here is what I would like to do when the user submits this form:

  • Form data is saved
  • Child window closes
  • Updating the parent window to display new data

How to implement this?

Should the form on childA.asp send data to another page (for example, "childB.asp") that saves the data, then calls the JavaScript function in the parent window, notifying it of the update, and then closes?

If so, how would you do it?

Thank you very much in advance.

+3
source share
1 answer

The Javascript code on your child page may link to the parent page via window.opener. So it could happen this way:

  • The subpage page submits the form to the server
  • The server does something and responds to the result page.
  • The result page is either the original form with errors, or a small page with a block <script>:

    window.opener.timeToReloadYourself();
    window.close();
    
+3

Source: https://habr.com/ru/post/1770790/


All Articles