Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

How to show popup when user tries to close browser window?

Thread view: 
Pasha - 09 Mar 2006 04:16 GMT
Hi all,

           I want to show popup when user tries to close browser
window. Like "Are you sure you want to close it" or "please logof
first" etc.If user clicks yes then browser window must not get closed.
Will you please tell me how should I do it?

          I have tried by using "onbeforeUnload()" event but if user
uses "alt+f4" to close
it will not work. And one more thing is that this solution is for IE
only I want the solution for
all browser.

If any one knows please tell me.

Waiting for your reply................

Thank you,

Prashant
Duane Evenson - 16 Mar 2006 15:22 GMT
> Hi all,
>
[quoted text clipped - 16 lines]
>
> Prashant

Change the default window behaviour:
    myFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

and add a WindowListener to your main window:
    myFrame.addWindowListener(WindowL);

Wherein you can handle your exit operations in
    public void windowClosing(WindowEvent e) , including having a
with a line like this:
    JOptionPane.showMessageDialog(null, "Bye, Don't forget to write.");
to have a farewell dialog box appear.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.