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.