This one is not mine — a coworker found it when IE 5.5 shipped. I included it in a report to MSRC because it was still working on IE 6 and, at the time, IE7 as well. Two lines.
How It Works
Normally, when a script calls window.close() on a window that the user opened by typing a URL or clicking a link, IE shows a confirmation dialog: “Do you want to close this window?” The browser only skips that prompt if it believes the window was opened via script.
By overwriting window.opener with a reference to the window itself, you convince IE that the window was opened programmatically. The next call to window.close() goes through without asking.
window.opener = window;
window.close();
That is all. On IE 5.5 and 6, this closes the browser window immediately. No prompt, no confirmation.
It was already widely known by 2006, which is part of why I called it out — the longer something like this stays unpatched, the more it gets quietly used. It is harmless in isolation, but combined with a resident script or a spoofing technique it becomes a slightly more annoying tool.
Reported to MSRC in 2006. This was one was patched long ago — Shared here as a historical record for learning purposes.