• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2212
  • Last Modified:

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

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
portal123
Asked:
portal123
3 Solutions
 
Cem TürkSenior Software EngineerCommented:
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
 
MasoudghCommented:
0
 
rama_krishna580Commented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
jay_gadhaviCommented:

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
 
JRevathiCommented:
I tried the above code.. it is not working for FF.........
window.close(); works for only pop-up windows..

Thanks
Bhanu Prakash
0
 
swistCommented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now