window.close() does not work in Firefox 2.0 upwards

Hi,
I have been trying to close a window using javascript and the window.close to no avail. I have found a few suggestions like:
. 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>

but that did not have any effect. So I am guessing it was for FF < 3.0 probably <2.0. I have also tried using window.focus() and self.close(). Also I am not trying to kill the window from a popup so it should not be a problem of javascript origin. Another 'solution' that failed was:
window.opener='';
window.close();
So does anybody know if there is a way of doing it or is it impossible?

schwagoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tomarse111Commented:
Are you trying to do this from the main window? i.e. not trying to close a popup and / or not trying to close the main window from a popup?
0
schwagoAuthor Commented:
Yes, I am trying to do this from a window I opened by hand and not with javascript. I get the error: a page not opened with javascript can not be closed with a script. I was wondering if it was possible to circunvent that.
0
Tomarse111Commented:
As far as I am aware the only windows you are allowed to close using javascript, are windows you have opened using javascript e.g. window.open() etc

Otherwise people could close your window at will, which could be incredibly annoying.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

amar31282Commented:
please set your firefox browser:

1.input "about:config " to your firefox address bar and enter;

2.make sure your "dom.allow_scripts_to_close_windows" is true



<script>
function closeMe()
{
var win=window.open("","_self");
win.close();
}
</script>
 
<html>
<body>
<form>
<input type="button" name="Close" onclick="closeMe()" />
</form>
</body>
</html>

Open in new window

0
amar31282Commented:
any update @schwago:

Regards,
Amarjit
0
swistCommented:
As far as I tested, for most browsers (includin ff2 & ff3, without need for changing browser conf.) this should work:
<input type="button" name="Close" onclick="javascript: window.opener = window.self; window.close();" />

Open in new window

0
kadabaCommented:
0
Michel PlungjanIT ExpertCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.