This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes parent.window.close() is working only for IE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "parent.window.close() is working only for IE" Watch "parent.window.close() is working only for IE" New topic
Author

parent.window.close() is working only for IE

Shashi Kala
Ranch Hand

Joined: Jan 27, 2008
Posts: 46
Hi all,

I have a hyper link i.e. 'logout'. When I click on it. the window should gets closed. To do so I wrote a javascript method as shown below.

function closing()
{
parent.window.close();
}
But this is working for only Internet Explorer..I have tried in Opera, Fire Fox, Netscape but in these browsers it is not working..I tried parent.parent.window.close() & top.window.close() functions too. But failed. Can anybody guess the problem here ??

With Regards,

Shashi Kala
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
It is browser security. If you did not create the window with window.open, you can not close it.

Eric
Shashi Kala
Ranch Hand

Joined: Jan 27, 2008
Posts: 46
Then, there is no other solution for this..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Correct.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shashi Kala
Ranch Hand

Joined: Jan 27, 2008
Posts: 46
Disappointed!! Thank you all.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Originally posted by Shashi Kala:
Disappointed!

Don't be. Just be glad that any old web site can't close your browser!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
As Bear stated, I am glad that I do not go to some site and my browser just goes away. I would be a little ticked if that would happen.

Eric
Shashi Kala
Ranch Hand

Joined: Jan 27, 2008
Posts: 46
Yah!! I can be glad
 
Consider Paul's rocket mass heater.
 
subject: parent.window.close() is working only for IE
 
Similar Threads
System.out.println in jsp
org.springframework.web.servlet.DispatcherServlet noHandlerFound error
Ant error: Make sure you have it in you classpath
How to reset password field?
IBM's RAD 7 - PMD