Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

execute action when window.close()

 
Imre Tokai
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!


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?


Regards
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic