CNET documents the annoying trend employed by low-rent websites: spawning new windows when you try to exit. The new windows contain all manner of advertisements, inducements, and crap you are certain to have no interest in.
I’m told porn sites have been doing this for years. I have no direct experience with this, of course.
One workaround is to surf with JavaScript disabled in your browser. This is not a great solution, though, because too many sites rely on JavaScript for basic site navigation.
As I mulled this over, I saw a potential solution.
First, the technical background… The annoying window-spawning behavior is enabled by an event handler called onunload, part of the JavaScript/ECMAScript language. Any JavaScript statements that appear in the onUnload attribute of an HTML document’s <BODY> or <FRAMESET> tags will be executed when the document is “unloaded” — when the browser window is closed, or when the user follows a link to another page. (Experiment here.)
And now, the solution: browser makers should give users a way to suppress this handler. For example, perhaps by pressing a key on the keyboard while closing the window, the browser can be instructed to ignore any onUnload calls. Or there could be a preference setting. There is a precedent for this: page authors can control whether links open in a new window, or target a specific frame, by giving a TARGET attribute to the <A> tag — and yet the user can override this through a variety of keyboard shortcuts or menu selections, e.g. “open this link in a new window” or cmd-click (on MacOS).
There are multiple benefits: less Internet congestion, fewer browser crashes, less disk space wasted by unwanted browser cache files, less meaningless traffic logged by advertisers, higher clickthrough rates on advertising, and overall less-annoying user experience (not that any of the advertisers seem to care about that one).