Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Close Pop up window in Forefox 4.0 using java script.

 
kartik reddy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you open it up with window.open?
Eric
 
kartik reddy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you didn't open the window, you can't close it.
 
kartik reddy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, is there any alternate solution for that?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. It is a security restriction.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for giving inputs on this issue.

- Kartik
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic