• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to capture popup window close event.

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Experts,

I am launching one jsp page from another environment as popup window. I have to capture the popup window's close event when user clicks on close sign on the browser.
I have used "onbeforeunload" attribute of body tag. This works if my jsp is launched on independent browser not as popup window.
Please help me.
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Puneet can you elaborate what you mean by pop-up window. I would say that they are the same thing. Are you using a popup javascript code like this



If yes, then this should not be a problem as both the popup and the original page would have the same source code. Please tell a little bit more about your problem...
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP, not JavaScript.

For more information, please read this.

This post has been moved to a more appropriate forum.

 
Puneet Chachra
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ankit, thanks for giving time to my problem. I tell you the exact scenerio. One applet is launched as a popup on click of a button from one environment, then a url is attached with this applet.

Means then my application is launched i.e. jsp page is launched in this applet, on that jsp close button is there. on click of close button, i perform some work. The same work i want to perform when user direct click on that applet close [*] button. I have used window's default functionality i.e. "onunload" or "onbeforeunload" functions, these functions work well if i launch my url in independent internet explorer, but in that applet popup, these are not working.
 
Puneet Chachra
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Please take the time to choose the correct forum for your posts. This forum is for questions on JSP, not JavaScript.

For more information, please read this.

This post has been moved to a more appropriate forum.



Dear Bibeault,

You must be knowing that what functionality i need is only possible through java script. If i write html page in place of jsp, then my question would be treated perfect for this forrum.
Please dnt do that. You are most welcome if you can solve my problem. Otherwise let others solve it.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Puneet Chachra,

Bear moved you post so people that know how to solve your problem would see it. He is not required to solve it. Be happy he moved it to the correct location and did not leave it in a place where people do not code JavaScript hang out. Just because it is a JSP means nothing. The technology you need is JavaScript and it acts no different on a JSP, .NET, CF, ASP, PHP, CGI, etc.

Your tone also did not come through nicely in your post. Remember that the posters here at JavaRanch are volunteers. We are trying to help you succeed at your job and studies. We are working free of charge to help you solve something that you are most likely getting paid for or graded on.

Eric Pascarello
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to capture the close button of the pop up window, than you would have to put the onbeforeunload or onunload in the pop up window and not in the parent window.

You would probably be better using a modal window where a value is returned when the window is closed. No need to reinvent the wheel.

Eric
 
Puneet Chachra
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks Eric. Extremely sorry actually i have not understood properly what Bear has done.

Continuing with the thread, i have used onunload or onbeforeunload function in an html page which is launching in that applet popup window, but how they are working when i click on the button that launches that popup. It means that these functions are working but on parent window.
How can i achieve this on popup window? Is there any different syntax in body tag as i have used <body onbeforeunload="fnUnloadHandler1()" onunload="fnUnloadHandler2()">. Please clear me on this.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you declare the functions also in the pop up window or are they only declared in the parent.

If in the parent you can use window.opener.functionName()

Eric
 
Puneet Chachra
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Yes Eric. I have declared the functions in a jsp which is launched in that popup window. My application has no concern with parent window. Through parent window, a new web application is called just through one link & jsp is displayed.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic