Solved

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

Posted on 2006-11-24
6
2,198 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
6 Comments
 
LVL 17

Expert Comment

by:cem_turk
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to hide the rows in Table when the value is empty ? 4 40
how can i remove string values 2 29
Javascript tutorials with real examples 5 25
Jquery 2 11
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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

773 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