I have a parent window and i open a pop-up window. I want to execute an action and to close the pop-up in same time.
I put the onklick = window.close event handler on submit button.
Now it works (very) strange: sometimes it does execute the struts action and close the window BUT sometimes it only closes the window (without executing the action)
How can I fix this?
posted 7 years ago
I think the problem is that you have a race condition between the submit and the onclick. I assume they are a synchronus and if your computer manages to execute the close first the submit won't happen. I'd suggest using a button and in the onclick event submit your form and then do your window.close. That should force them to happen one after teh other.