Lightbox for Modal Dialogs Redux
Jul 10 by
Andre
Since I last posted on Lightbox for modal dialogs in May, some additional relevant projects have sprung up. This is a roundup of more Lightbox-type modal dialog options. As you go about choosing the perfect script for your needs, Here are some questions to keep in mind:
- What's your content? Do you need to just display images? Or arbitrary HTML? Many scripts support both, and some are tailored around displaying images very easily.
- Is your content remote? You may need to retrieve your content from the server, or the content may already be rendered on the page in a hidden div. I actually find the second case the more common one -- the dialog content is already loaded on the page, and I just want to reveal it in a modal window.
- What are your bandwidth requirements? These scripts vary quite a bit in size. If you're building an internal application you can get away with a bulkier script, but otherwise you might want to look for one of the leaner ones.
- How important is look-and-feel? Some of these scripts offer a slick and customizable look, and others are more spartan. I appreciate the nice looking options, but usually end up using the scripts with less flourish. Your needs may be different.
- What JS Library are you using? Prototype? Moo.fx? Dojo? jQuery? Your choice may narrow the field for modal scripts, since you typically will not include another whole JS library just for the modal dialog functionality.
The Scripts
|
iBox
iBox covers the three main cases for modal dialogs: images, inline content, and AJAX-loaded content. The result for all three is attractive and functional. iBox is also quite small (11K), and doesn't depend on any external JS libraries. As an added bonus, iBox supports graceful degradation for browsers with JavaScript disabled (i.e., it will simply link to a new page with the content).
|
|
Seth Banks' subModal
subModal has been around for a while -- it actually pre-dates the Lightbox craze, and is the product of Seth's work from when AJAX was called DHTML. Submodal does just one thing -- load external content and display it in a modal dialog -- and it does it reasonably well. It's a bit clunky in its implementation however, as it requires multiple JS files and extra markup on your page. Note also that each time a submodal window opens, your browser history gets an extra item. This is a product of the iFrame usage, and may or may not be your desired behavior.
|
|
Todd Huss' subModal enhancements
Todd has taken Seth's subModal work (see above) and made a few key enhancements. First, it's unobtrusive -- you can make any HREF into a modal window just by adding a class to the anchor tag, and you no longer need to add special markup to your page to utilize the script. Second, it's consolidated and compressed -- the script lives in just one .js file, and that file has been compressed to just over 4K using Dean Edward's Packer tool. The underlying architecture of the modal dialog is still the same -- it uses a iFrame to load external content, and it still adds a history entry for each modal that is displayed.
|
|
Prototype window
Prototype window is a general-purpose JavaScript windowing system which also happens to support modal dialogs. It offers an impressive array of styles and effects out-of-the-box. As the name implies, it is dependant on the Prototype JavaScript library. You can utilize Scriptaculous effects to show/hide your windows (for example, fading in windows). This looks great in demos, but in practice quick response is almost always preferable to fancy transition effects. Some positives for this script: 1) it's pretty -- check out the dropshadow style; 2) it's very well documented; 3) it includes multiple styles to choose from, and instructions for creating additional styles; 4) it includes a cookie-based system to remember windows' positions (nice, but not applicable if you're using it for modals).
|
|
Lightbox v2.0
The original work by Lokesh Dhakar. Allows pictures and sequences of pictures, not arbitrary HTML. Very slick animation effects if you are open to the heavy prototype+scriptaculous download. The animation and overall polish of the out-of-the-box presentation gives Lightbox the biggest "wow" factor of the three.
|
|
Greybox
Greybox allows arbitrary content instead of just pictures. There are two versions: the original, by Amir Salihefendic, and Greybox Redux created by John Resig, author of jQuery. The advantage of John's version is that it the code footprint is quite small -- just 1.2K on top of the jQuery library, which is about 10K. If you are already using jQuery, then John's version is the clear choice. It also fixes a back button bug in the original. This is the only one which uses an iFrame, so you can show a completely separate document inside the popup.
|
|
Thickbox
Thickbox is written by Cody Lindley, and is built on top of jQuery. Thickbox has the advantages of both versatility (images and html) and relatively light weight (20K including jQuery). Part of Cody's motivation was a generalizable custom dialog box, and Thickbox fits the bill well. Thickbox's footprint is not quite as small as John's Graybox, but still much smaller than Lightbox. New in version 1.2: The ability to use inline div elements to populate a ThickBox. The new version also utilizes jQuery 1.0 alpha, which as of this writing (7/9/06) is still stabilizing on its way to 1.0.
|
TrackBack URL:
Listed below are links to weblogs that reference Lightbox for Modal Dialogs Redux:
» 101 ways to do Modal dialogs on web pages from Tim Haines
Okay, so it's not 101, but there's a lot of tools out there now. Andre at Earthcode.com has a write-up... [Read More]








Comments
AhmedF on Jul 10
Nice post, good to see an explanation on all of them.
Todd Huss on Jul 10
Awesome roundup Andre! When I was looking for a solution I remember spending a few hours googling just to put together the list of candidates so I'm sure this will be a big help for people just getting into modal dialogs!
Derek Haynes on Jul 10
Great review Andre! I was struggling with a hacked-up version of Lightbox Gone-Wild for a while, and it looks like there are much better alternatives now.
Andreika on Jul 13
You can also add my attempt to your review: http://okonet.ru/projects/modalbox/
Thanks!
Jack Turner on Sep 02
And there is the excellent Litebox which uses moo.fx to emulate the behavior of Lightbox 2.0 in 24K or less.
Rich on Sep 06
I've just discovered Redbox (yet another alternative)...
http://richtextblog.blogspot.com/2007/09/redbox-rules.html
Mikel Maron on Sep 23
Hey Andre -- Have you had success with using any of these as containers for a GMaps API map? I need a google map with markers to appear within a lightbox..
I've tried both Leightbox and iBox, and both have some problems.
Andre Lewis on Sep 23
Hey Mikel - I haven't put GMaps in a lightbox, but I know I've seen it someplace -- maybe Zooomr. Let me know when you find the right mix, I'm sure I'll want to do that at some point.