Web Hosting Talk







View Full Version : window.close() on Firefox


BM136
11-30-2008, 12:09 PM
Hello,
I created a web page include a button, and I added onclick event on the button to close the window, but the button works well on IE, but it doesn't work on Firefox
any help??

JayShah
11-30-2008, 12:30 PM
Tell us what the error is? Use something like FireBug to see it if you can't already.
Jay

BM136
12-01-2008, 06:07 AM
Hi Jay,
It doesn't return any error
my code as the following:
<html>
<head>
</head>
<body>
<input type="button" value="close" onclick="window.close();"/>
</body>
</html>
I read somewhere while I was searching that in Firefox I can't close a window via javascript unless I open it via javascript

HivelocityDD
12-03-2008, 01:29 AM
Can you please try this
onclick=\"javascript:window.open('','_parent','');window.close();\"
This should work both with IE and firefox
Cheers !

BM136
12-03-2008, 03:15 AM
nop,
It didn't work :(

HivelocityDD
12-03-2008, 06:31 AM
If you are using older version of firefox it should work. But for higher versions above 2.2 it wont work I think.
Can you please try this
<input type="button" value="close" onclick="javascript:window.opener='x';window.close();"/>
Let me know if you have any luck with this please..

BM136
12-03-2008, 07:05 AM
no good news, not working

killapix
12-03-2008, 02:28 PM
I read somewhere while I was searching that in Firefox I can't close a window via javascript unless I open it via javascript
Thats correct
To use the close method in FF you must use the open method..;)