Results 1 to 7 of 7

Thread: Little question on close script

  1. #1
    Join Date
    May 2007
    Posts
    99
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Red face Little question on close script

    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?

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

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    are you just trying to close the current window??

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

  3. #3
    Join Date
    Jan 2007
    Location
    Charlotte, NC
    Posts
    82
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

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

  4. #4
    Join Date
    May 2007
    Posts
    99
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    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?

  5. #5
    Join Date
    Jan 2007
    Location
    Charlotte, NC
    Posts
    82
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    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?

    Thanks

  6. #6
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    try
    Code:
    <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?

  7. #7
    Join Date
    May 2007
    Posts
    99
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    I'm not just using the empty anchor. I have an actual link in there. So what I have looks like this:

    Code:
    <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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •