Non-closable windows in Safari

I've been running into a weird problem in Safari 3.2.3 lately:

Sometimes, a window will appear that has a grayed-out (and thus non-clickable) Close button.

Quitting and restarting Safari and then reopening windows from previous session doesn't fix the problem. There just doesn't seem to be a way to close the window.

I think this has something to do with "pop-under" advertising windows. Though there are also suggestions online that it has something to do with input managers.

At any rate, my solution the last few times has been to quit Safari and edit the ~/Library/Safari/LastSession.plist file using the property list editor application. Delete the offending window, and everything's fine. But that's really not a very good solution.

Just now, I found a better one, which I'm posting just in case anyone else runs into the same problem:

In the URL bar of the window that can't be closed, type the following:

javascript:window.close();

And press Return. The window should close. (It's possible it'll ask if you really want to close the window, in which case click the OK button or equivalent.)

This also works:

javascript:self.close();

Obviously, don't type that in a window that contains any information you don't want to lose.

P.S.: Doing the above may result in another window becoming invisible. I don't understand that, either, but if none of your windows are foregrounded, and the Window menu shows a checkmark next to the title of a window you can't see, then you can choose File > Close Window (or the equivalent keyboard shortcut) to close the active-but-invisible tab. If the invisible window contains multiple tabs, you'll have to repeat that Close action multiple times. Eventually, all the tabs should be closed and Safari will be back to normal.

3 Responses to “Non-closable windows in Safari”

  1. smfr

    Hi Jed

    If you go back to the page that was loaded in an unclose-able window manually (rather than just re-launching and relying on the LastSession.plist), does it go back into the unclose-able state?

    Also, is it possible to reproduce at will the situation where closing one window makes another one become invisible?

    Bug reports on both issues would be welcome at http://bugreporter.apple.com, or just email me with steps to reproduce if you can.

    Simon

    reply
  2. Jed

    Hi, Simon — nope, it’s not a problem with the page itself; at least a couple of times, the page in question has been one of my own PHP pages, containing only code that I wrote myself, and that has worked without a problem for years. So if I get rid of the instance without the close box, and then go back to that page, everything is fine.

    The instances without the close box also have other weird behaviors—they’re sometimes associated with an invisible window (also containing a page of my own that’s always worked before), and there are often weirdnesses around unclosable windows staying in front when I click other windows to bring them forward.

    Unfortunately, I can’t reproduce anything about this situation at will. I think they’re associated with pop-unders, but that’s just circumstantial, and I’m hoping I’ll have fewer pop-unders now that I’ve turned “Block Pop-Up Windows” back on—not sure why I turned that off. Also, the problem started somewhere around the time that I installed both 1Password and TextExpander, so I don’t know whether either of those have anything to do with it.

    The problem has only happened two or three times. Maybe as many as four, but I don’t think more than that.

    If it does happen again—and if I’m not in the midst of trying to get something important and time-sensitive done—then I’ll try and figure out parameters and file some kind of bug….

    reply
  3. smfr

    > Password and TextExpander
    One (or both) of these could certainly be the culprit. They do evil things behind Safari’s back to work their nefarious magic.

    reply

Join the Conversation

Click here to cancel reply.