This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Close Pop up window in Forefox 4.0 using java script. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Close Pop up window in Forefox 4.0 using java script." Watch "Close Pop up window in Forefox 4.0 using java script." New topic
Author

Close Pop up window in Forefox 4.0 using java script.

kartik reddy
Greenhorn

Joined: Dec 11, 2008
Posts: 9

Hi does anyone have a code to close the browser window using Firefox 4.0?
This code needs to be used to close a pop-up window.

When I open a window and try to press the button to close it, it doesn't work in Firefox 4.0.
Code is: javascript:window.close();
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Did you open it up with window.open?
Eric
kartik reddy
Greenhorn

Joined: Dec 11, 2008
Posts: 9
Hi Eric,

It works fine when I use with window.open
i.e., When I open a window using window.open() and try to press the button to close it using javascript:window.close(), it works fine.
But the most interesting thing is when I don’t use window.open() and try to close the current window it doesn’t work.
Could you please give any suggestion, how to proceed further?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

If you didn't open the window, you can't close it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
kartik reddy
Greenhorn

Joined: Dec 11, 2008
Posts: 9
Ok, is there any alternate solution for that?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

No. It is a security restriction.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Older versions of browsers have hacks to close the window, but that is coding against a browser flaw. It is talked about a lot here in the past. Modern day browsers have the flaw patched in most cases.

Eric
kartik reddy
Greenhorn

Joined: Dec 11, 2008
Posts: 9
Thanks a lot for giving inputs on this issue.

- Kartik
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Close Pop up window in Forefox 4.0 using java script.