schwago
asked on
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:closeWind ow();">Clo se 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?
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:closeWind
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?
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?
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
any update @schwago:
Regards,
Amarjit
Regards,
Amarjit
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();" />
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.