Annoying and Intrusive Sites
As of December 2011, this topic has been archived. As a result, it is no longer actively maintained. For more information, see Archived Content. For information, recommendations, and guidance regarding the current version of Internet Explorer, see Internet Explorer Developer Center.
May 1, 2001
(Updated November 2007)
Ever notice that some Web sites just have a way of getting in your face? Yep, I'm talking about sites that cause other browser windows to mysteriously appear as you navigate to or from a page. And often, these surprise windows display nothing more useful than online advertising. This functionality, commonly referred to as pop-up windows, is usually achieved by script on a page calling the window.open method. (For details. see open Method.) Though its use can be irritating, when used properly, the window.open method can also allow for extremely powerful applications to be built.
The Internet Explorer team frequently receives requests to allow users to disable the appearance of pop-up windows. Yet this puts us in a dilemma: Do we allow developers the freedom to use this potentially powerful tool to offer great solutions to their customers? Or do we restrict the platform so developers cannot misuse this functionality? The Internet Explorer team has taken the stand that except where security concerns are present, we should allow developers as much flexibility as possible to build powerful applications, without undue restrictions.
This month I'd like to discuss why the pop-up window functionality is necessary. I'd also like to recommend a few practices that should help keep visitors on your site—or at the very least, keep them from leaving out of irritation.
The ability to show other windows so users may view related content without losing context is extremely useful and is well utilized in many places on the Web. Often, the user is hardly aware that another window is utilized, as it appears a natural extension of the task they are trying to achieve.
An example of good use of the window.open functionality is MSDN's online references for Internet Explorer. Open the Web page, onblur Event in your browser. If you scroll down, you'll see some sample code and a 'Show Me' button so you can see the sample code in action. When you click this button, the sample is shown running in isolation in a new window. This is highly useful in this circumstance, as the context is maintained for the user, who can see both the sample and the reference page at the same time.
Were browsers to restrict the window.open functionality, a great many sites on the Web today would be broken. While we might not mind breaking some sites that just create pop-up advertisements, there are many sites that make legitimate use of this functionality.
Let's look at what I think is the most obscene usage of this functionality, and I use the word obscene here deliberately, for it tends to happen on the most obscene sites. I call it 'trapping the user'; whenever you click a link to another page, or attempt close the browser window, some script on the page traps the event and proceeds to open yet another browser window. This technique seems to be used most often on porn sites.
This practice can be most irritating, especially when you stumble into the site accidentally through an inadvertent search on the Web, only to find that you suddenly have five or six windows open with obscene images in them—and every time you try and close one of them, another two appear! Not only is this irritating, it can also be extremely offensive, and the innocent user may feel the only way to escape the endless stream of images is to use the reset button on the computer.
Of course the sites that do this are after eyeballs to help pay advertising revenue, and as such, are unlikely to follow the recommendations I make about best use of this functionality. Nevertheless, I'll make a heartfelt plea that such sites refrain from trapping the user, and also rate their content appropriately (for more information, see Internet Ratings) so that users can set their browser to avoid it.
The following is an outline of what I consider to be best practices with regard to this technology. Ultimately the choice is yours how to use this functionality, but keep in mind that if you misuse it, visitors to your site are likely to become irritated and therefore less apt to return.
- Think about the audience for your site. Do they actually understand the concept of multiple windows?
The readers of this column no doubt understand how to have multiple applications running at the same time, and how to switch between them. Consider, however, the less experienced computer user, for whom managing multiple windows may seem an overwhelming task. If you expect inexperienced users to frequent your site, it may well be appropriate to offer the entire user interface to your site in a single window, so that users do not lose context and get lost switching from one window to another.
- Only open a new window in direct response to a user action, and think about how to make it clear to the user that their action will open a separate window.
In my view, one of the most irritating things for any computer program to do is to open a new window without the user having initiated an action If you use window.open only in direct response to a user action, then the user will associate the action with the result. If there is a long delay between a user action and a result, then the user will struggle to make an association between the two.
- Do not use a pop-up only to display an advertisement.
An advertisement is unlikely to get a user's positive attention if it is not part of the primary site they are visiting.
- Do not trap visitors in your site.
It may be appropriate to prompt a user when they are leaving your site to see if they wish to save some state. Trapping them by opening another window, however, is simply rude, and will hardly entice the user to return.
Use Dynamic HTML to Avoid the Use of Pop-Up Windows
Dynamic HTML is extremely powerful and allows you to build flexible applications. A few years ago, the entire Web was static; every time you clicked a link, an entirely new page was ent by the server back to the user. Then Java, plug-ins, and ActiveX Controls were used to allow users greater interactivity, yet these failed to integrate well with the HTML content of the page. With the emergence of Dynamic content support in Internet Explorer 4.0, and the subsequent enhancements to this functionality in version 5.0, 5.5, and now the 6.0 preview, there is a much richer set of functionality available.
This rich functionality allows you to offer solutions where all user interface takes place in a single browser window, and users feel they are operating a full application. One of my favorite examples of this is at http://www.blox.com. (Editor's note: Sorry, this site is unavailable on the Web as of November 2007.) This company offers online spreadsheet and presentation software that runs in the Internet Explorer browser without any additional components being installed. Due to the power of this solution, it does require that Internet Explorer be used to visit the site and run the applications. Yet it demonstrates the kind of rich Web experience that can be achieved without the use of irritating extra windows.
One technique that can be used to provide separate content as part of a page is "inline frame," often known as IFrames because of the <IFRAME> tag used. IFrames offer the ability to have a separate HTML document displayed as part of a parent document. (See IFRAME Element | iframe Object.)
Now that Netscape 6 supports this functionality (it has been available in Internet Explorer since version 3), we may see an increased use of this technique on the Web. By use of this method, you can avoid the overhead and layout limitations associated with framesets, and manage content on a site more efficiently.
Another technique whereby multiple browser windows may be avoided is the use of HTML dialogs to interact with the user in the context of their browser window. See The Importance of Good Dialog, an article I wrote last year that covers this approach.
A Final Hint
As the focus of this column was on new windows, I thought I'd finish with a hint for Internet Explorer power users that many seem to be unaware of. When you click a hyperlink sent to you in e-mail, you may find that the page referred to appears in a browser window that is already open. The reason for this is simply to make most efficient use of the resources of your computer. Nevertheless, we also recognize that for power users this might not be desirable behavior. Therefore, you do have the option to always open fresh browser windows.
To implement this, go to the Tools menu and select the Internet Options… dialog. Under the Advanced tab make sure the Reuse windows for launching shortcuts option is not checked. Since I spend much of my time with many browser windows open and following hyperlinks sent to me in e-mail, I have this option unchecked. This allows me good granular control of all the browser windows I have open.
David Massy occasionally wears sun glasses and pretends to be a dude, but when the dark glasses are removed, he works as a technical evangelist on Windows and Internet Explorer technologies, which means he talks to customers of Microsoft about how they might best use the technologies. Before becoming a technical evangelist, Dave worked on the Internet Explorer team as a program manager. Since Dave is originally from England, he is valiantly struggling to educate his American colleagues on how to correctly pronounce "tomato."