View Full Version : Little question on close script

03-13-2008, 06:26 PM
This one should be so easy. But not for me. All I want is a close script that works in Firefox as well as IE, that doesn't make an alert box come up. All the ones I have found make that Windows alert come up that says "The web page you are viewing is trying to vlose the window. Do you want to close this window?" I don't want that.

I love this one, because the window closes nice and clean, without that alert crap. But it only seems to work in IE. Is there one like this that works in FF too? :confused:

<a href="javascript:window.opener='x';window.close();">Close</a>

03-13-2008, 08:21 PM
are you just trying to close the current window??

<a href="javascript:self.close()">Close This Window</a>

03-13-2008, 08:48 PM
<a href="#" onclick="window.close(this);">Close</a> also works and using the onlick handler rather than href=javascript: is the more preferred method.

03-14-2008, 02:28 AM
Hi boogyman, thanks for the reply. That was one of the ones I tried, but it makes that Windows alert box come up.

Jamiller, when I use the one you gave me, I'm getting a 406 error:
"The resource cannot be displayed"

Am I missing something? :confused:

03-14-2008, 01:17 PM
Strange, I'm assuming because I have <a href="#" it's trying to find # and coming up empty because it's not there. This is the code I use all the time to close a popup. What browser are you using and what is the doctype of your html page?


03-14-2008, 03:10 PM

<a href="javascript:void(0)" onclick="self.close()">LINK TITLE</a>

# refers to an anchor, so it's referring to an empty anchor, which could be the reason you are getting an error.
most undoubtedly because of IE rendering engine is attempting to be smart, but really messes up ... i dunno? :confused:

03-14-2008, 06:04 PM
I'm not just using the empty anchor. I have an actual link in there. So what I have looks like this:

<a href="http://google.com" onclick="window.close(this);">Close</a>

I'm in IE6, and it's being done in FrontPage.

Also, I want this close thing to work for popups, and regular pages. :o