Solved

window.close() do NOT work on FireFox..

Posted on 2006-11-24
6
2,204 Views
Last Modified: 2009-05-29
I used the following code to close window. It works on I.E, but not FireFox. How can I resolve a problem??

<FORM>
<INPUT TYPE="button" VALUE="LogOut" onClick="window.close()">
</FORM>
0
Comment
Question by:portal123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 17

Expert Comment

by:Cem Türk
ID: 18010158
its a security issue with FF you cant close a window except it is a pop-up window (that opened by window.open method)
0
 
LVL 3

Assisted Solution

by:Masoudgh
Masoudgh earned 160 total points
ID: 18010785
0
 
LVL 23

Accepted Solution

by:
rama_krishna580 earned 170 total points
ID: 18012041
Hi,

1. Copy/paste the following code to the head of your page…

<script language="javascript" type="text/javascript">

function closeWindow() {

window.open('','_parent','');

window.close();

}

</script>

2. Set your link like this:

<a href="javascript:closeWindow();">Close Window</a>

R.K
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Assisted Solution

by:jay_gadhavi
jay_gadhavi earned 170 total points
ID: 18026346

This code works in both IE and FF ----

<html>

<head>
<SCRIPT language="JavaScript">
<!--
var browserName=navigator.appName;
if (browserName=="Netscape") {

function closynoshowsme()
{
window.open('','_parent','');
window.close();}
}
else {
if (browserName=="Microsoft Internet Explorer")
{
function closynoshowsme()
{
window.opener = "whocares";
window.close();
}
}
}

//-->
</SCRIPT>

</head>

<body>
<a href="javascript: closynoshowsme();">Close Window</a><br /><br /><br />
<button type="button" onclick="closynoshowsme();">Close this window</button>
</body>
</html>

0
 

Expert Comment

by:JRevathi
ID: 22958661
I tried the above code.. it is not working for FF.........
window.close(); works for only pop-up windows..

Thanks
Bhanu Prakash
0
 

Expert Comment

by:swist
ID: 24501295
As far as I tested, easiest way to close window for most browsers (including ff2 & ff3, without need for changing browser conf.) is this:


<input type="button" name="Close" 
onclick="window.opener = window.self; window.close();" />

Open in new window

0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question