A multi-window user interface benefits end-users by conserving desktop real estate, differentiating between navigation and destination, accommodating tangential data without losing focus on primary data, and so on. This is well-worn territory for application developers. Although beneficial, developing a multi-window UI for the Web is not a trivial task. This two-part article demystifies multi-window UI design, and includes cut-and-paste JavaScript code of practical windowed UIs that can run in both Netscape Communicator and Microsoft Internet Explorer. Note: The code in this article has been tested and works on 4.x (32-bit) versions of Communicator and Internet Explorer. Multi-window UIs are increasingly common on the Web. Some are designed well, many are not. Adult sites, for instance, are notorious for trying to entice (if not severely confuse) potential customers by launching a barrage of popup windows when users attempt to leave—an obnoxious ploy reminiscent of the old JavaScript window bomb that would proliferate popups on the unwitting user’s desktop until either the browser or OS failed. In part one of this article we will look at the utility of popups for enhancing site accessibility and user experience. Let’s cut to the chase. The cardinal rule of windowed Web design: Subwindows should not require more user intervention than if users had remained in the primary browser window. For example, JavaScript scripted windows often force users to exit manually by clicking a close button or using the operating system’s close method. This isn’t necessary, nor even desirable in many instances. Self-closing popups can help ease the burden of site navigation. Here are some recommended implementations. Closing with onBlurPlace
Click example 1!
Closing with setTimeout()To automatically close a popup after a specified duration, use
Click example 2! You can also use
Click example 3! Closing with onUnloadTo close a popup when the primary window file (the opener) unloads, use a JavaScript function call in the
I wrote the code in this next example for eMirage [ designer imitations ], a retail site specializing in generic versions of name-brand products. Here, when users leave a product-specific page any open popups launched from that page automatically close. Click example 4, then click your browser Reload button! This code is both unique and temperamental.
Function Definition:var faux = null; function copyCat(url,w,h) { function flush() { Since
Seasoned JavaScript scripters will notice a coding anomaly in
Function Invocation:onUnload="flush()"As noted above, place the function call in the
Don’t confuse the code in the above example with the
Adding
Note that you can also automatically close a child window when a dependent
Closing with conditional statementsCode conditional statements that will close the popup when certain conditions exist. Consider a transitional popup I developed for Novell’s Web-compatible documentation. The popup—which provides links to various Novell Web sites—opens a third window. Note the code in the popup .htm file that closes the Novell Web Links popup: var whoAmI = navigator.appName; function findMe(url) { This code queries whether variable
Click example 5! Function
Brent Lee Metcalfe is a corporate information architect for Novell Inc. Among other things, he designed and engineered the Web-based documentation user interface for several Novell® products, including Novell BorderManager™, Z.E.N.works™, and forthcoming NetWare® 5.0. Brent has been published in c|net’s builder.com, and he runs im@go w3 design in his spare time (whatever that is!). He can be pestered here or there. Portions Copyright © 1998 Novell Inc. All rights reserved. Used with permission. |