• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

execute action when window.close()

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic