As such, you have to work within this by having the following:
- Main application creates instance of form
- Main application queues up the "constructor" variables
- Main application creates listener for a form postMessage event
- Form has function receiveMessage to process received JSON
- Form, after starting, fires the specified event back to the main application.
- The main application listener can now execute postMessage to the form which is now able to process the message
- The form then has to process the contents of postMessage to which it already has a listener.
By using JSON we can send different payloads and have the "constructor" selected dynamically. Of course, this could be done in a number of other ways such as queue up constructor on the server for the form to collect, pass the constructor variables in the URL called in window.open(..). I think this method is slightly less clunky, although not exactly perfect...