window close javascript does not work in mozillla[SOLVED]

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

window close javascript does not work in mozillla[SOLVED]

Post 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>
Last edited by raghavan20 on Sat Oct 15, 2005 6:50 pm, edited 1 time in total.
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

try window.close(); instead.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post 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>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you don't need to specify javascript in the onclick
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post 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>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post 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. :?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

because javascript shouldn't be able to close a window it did not create... that's not all that hard to understand.. :?
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post 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.
Post Reply