Closing the browser window/tab in mozilla/safari

Hi,

How could close the browser window in mozilla or safari.

window.close is working in IE/Opera but not in mozilla/safari?

Can any one help me out?

Thank you,

b

Hi babuacp, welome to the forums.
window.close() works for me in Firefox.

<html><head><title>close window test</title>
<script type="text/javascript">
function say_bye(){
window.close();
}
</script>
</head>
<body>
<div onclick="say_bye();">click here to close window</div>
</body></html>

What does your code look like?

Thanks for your reply.I tried the above code but it is not working for me.

and also below too.

<a onclick=“window.close();”>click here to close window</a>

Thank you,

What version of Firefox are you using?
Are you certain javascript is enabled?
Any plugins or extensions that could be involved?
Does the following give an alert?

<html><head><title>close window test</title>
<script type="text/javascript">
function say_bye(){
alert("closing");
window.close();
}
</script>
</head>
<body>
<div onclick="say_bye();">click here to close window</div>
</body></html>

I am using firefox 3.0.1, and its not working in 2… .Yes , its giving alert message.and javascript is enabled.

Thank you

I’m using Firefox, IE, Flock, Safari, Netscape Navigator and Opera and this code works fine in all of them:

<a href="javascript: window.close()">Close</a>

mexabet and Mittineague,

Are you using for popups?

I have seen some ifo here:
http://www.webdeveloper.com/forum/showthread.php?t=153088

thank you,

not for the popups.i am not sure hwy is n’t working?

Did you open the window with JavaScript in the first place?

JavaScript is not allowed to close windows it didn’t open.

:fangel: I could have sworn I tested the above in Firefox and it closed. But now (after upgrading to 2.0.16) it doesn’t and I get the error console message

Scripts may not close windows that were not opened by script.
so I don’t know what I did before (tested in Opera thinking I was using Firefox?? tesing a different window.open()/window.close() script??).
Sorry for the confusion, but if you google the error message you’ll see this has been around for a while.

okay… thank you…is there any other way we could close the window(which is not opened by javascript)?

no way??

thank you,

if you didn’t open the window then the only way to close it is to be logged on to that computer either by sitting in front of it or by getting the person whose computer it is to enable remote support.

thanks!