Page 1 of 1

window close javascript does not work in mozillla[SOLVED]

Posted: Fri Oct 14, 2005 5:30 am
by raghavan20
This does not work in Mozilla but works in IE.
any suggestions to make it work in mozilla.

Code: Select all

<p align="center">Click here to <a href="javascript:self.close();">close</a> this window</p>

Posted: Fri Oct 14, 2005 6:25 am
by foobar
try window.close(); instead.

Posted: Sat Oct 15, 2005 5:57 pm
by raghavan20
thanks foobar, i also saw the same in Mozilla site...
but for some reason it does not work in my Mozilla browser

Code: Select all

<a href = "" onclick = "javascript:window.close();">close me </a><br />
<a href = "javascript:window.close();">close me </a>

Posted: Sat Oct 15, 2005 6:05 pm
by feyd
you don't need to specify javascript in the onclick

Posted: Sat Oct 15, 2005 6:22 pm
by raghavan20
This does not work again.
Javascript is enabled in Mozilla...i jus checked it now...

Code: Select all

<a href = "#" onclick = "window.close();">close me </a>

Posted: Sat Oct 15, 2005 6:34 pm
by feyd
if the window wasn't opened via javascript, Mozilla may not let you close it. That's the behaviour in 1.5 Beta 1 and Beta 2 anyways..

Posted: Sat Oct 15, 2005 6:49 pm
by raghavan20
thanks for the answer feyd, i tried it...it works as u say??
I dont really know why they chose to do it that way. :?

Posted: Sat Oct 15, 2005 6:57 pm
by feyd
because javascript shouldn't be able to close a window it did not create... that's not all that hard to understand.. :?

Posted: Sat Oct 15, 2005 7:03 pm
by raghavan20
I understand that...but why dont the mozilla allow when IE allows.
Cos in many situations during redirection, we might need this property to work.

Posted: Sat Oct 15, 2005 7:06 pm
by feyd
Redirection stays in the window, why close it? IE has incorrect implementations of many parts of the standards, along with poor ideas of security..

Posted: Sat Oct 15, 2005 7:13 pm
by raghavan20
sometimes i feel it better...
ex:
you purchase a few items...check out using paypal...paypal directs bk to your site...you display thanks message...the dialogue ends there...it wld be nice if we offer the viewer, the link to close the current window.