File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Open a window on close of main window Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Open a window on close of main window" Watch "Open a window on close of main window" New topic
Author

Open a window on close of main window

Pashi Soni
Greenhorn

Joined: Feb 27, 2003
Posts: 26
Hi,
On close of the main window, I want to popup a small window. The main window can be closed by the cross button on the right most side of the browser or by javascript window.close() or by ALT F4 key of the key board. How to catch this close event and pop up a new window.
Regards
Pashi.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
use
window.document.onunload=new window("","","");
write this in the head section, just before body..
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1028

use
window.document.onunload=new window("","","");
write this in the head section, just before body..

...and loose visitor by visitor for ever
Pashi Soni
Greenhorn

Joined: Feb 27, 2003
Posts: 26
Hello,
I tried the code, but instead of poping a new window on unload, it is loading on load. So it is not working properly. Please Help. !!
thanx
Pashi
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1028
Hi Pashi
<body onUnload="window.open( ' ', ' ', ' ' )">
but if you pop up advertising, better use
<body onLoad="history.back()">
[ May 08, 2003: Message edited by: Christian Baron ]
Pashi Soni
Greenhorn

Joined: Feb 27, 2003
Posts: 26
Thanx now it is working perfectly.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
Hey have you tried to use a link on your page that you have this code on??? LOL...I would do it if I were you!
 
 
subject: Open a window on close of main window
 
Threads others viewed
How to close a frame by clicking Esc Button?
How to make the browser to go into full screen mode onload
Close main window from popup window
invalidating the session on closure of browser
How to close the Frame by clicking the Esc Button?
developer file tools