OVERVIEW
Lightbox is a simple, unobtrusive script used to overlay images on the current page. It's a snap to setup and works on all modern browsers.
WHAT'S NEW IN VERSION 2
- Image Sets: group related images and navigate through them with ease
- Visual Effects: fancy pants transitions
- Backwards Compatibility: yes!
HOW TO USE
PART 1 - SETUP
- Lightbox 2 uses the Prototype Framework and Scriptaculous Effects Library. You will need to include these three Javascript files in your header (in this order).
<script type="text/javascript" src="js/prototype.js"></script> <script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" src="js/lightbox.js"></script>
- Include the Lightbox CSS file (or append your active stylesheet with the Lightbox styles).
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
- Check the CSS and make sure the referenced
prev.gif
andnext.gif
files are in the right location. Also, make sure theloading.gif
andclose.gif
files as referenced near the top of thelightbox.js
file are in the right location.
PART 2 - ACTIVATE
- Add a
rel="lightbox"
attribute to any link tag to activate the lightbox. For example:
Optional: Use the<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>
title
attribute if you want to show a caption. - If you have a set of related images that you would like to group, follow step one but additionally include a group name between square brackets in the rel attribute. For example:
No limits to the number of image sets per page or how many images are allowed in each set. Go nuts!<a href="images/image-1.jpg" rel="lightbox[roadtrip]">image #1</a> <a href="images/image-2.jpg" rel="lightbox[roadtrip]">image #2</a> <a href="images/image-3.jpg" rel="lightbox[roadtrip]">image #3</a>
DOWNLOAD
CHANGELOG
- v2.04 - 3/9/08
- NEW - Upgraded Prototype from v1.4 to v1.6.0.2
- NEW - Moved label text into configuration for easier localization
- UPDATED - Code cleaned up. Respect for the global namespace and native javascript objects.
- FIXED - Caption displays as "null" when viewing an uncaptioned image after viewing a captioned image.
- FIXED - Clicking 'close' button shifts layout as link focus' dotted line appears.
- v2.03.3 - 5/21/07 - Support for horizontally scrolling pages. Added updateImageList method for ajax'y pages.
- v2.03.2 - 4/30/07 - Fixed animated gif support in IE/Opera.
- v2.03.1 - 4/18/07 - Fixed embed hiding. Overlay opacity var added to config. Image sets w/Imagemaps fix. Clearfix removed.
- v2.03 - 4/10/07 - Improved keyboard navigation. Animation off toggle. Hides Flash movies under overlay. Imagemap support. Valid CSS.
- v2.02 - Fixed layout issues caused by multiline captions. Added keyboard navigation.
- v2.01 - Centering in IE6 (any DOCTYPE) fixed. Smoothed out resize transition.
SUPPORT
- It doesn't work at all. The image opens up in a new page. What's wrong?
- This is commonly caused by a conflict between scripts. Check your body tag and look for an onload attribute. Example:
<body onload="MM_preloadImages(‘/images/menu_on.gif’)…;">
A quick fix to this problem is to append theinitLightbox()
to the onload attribute as so:<body onload="MM_preloadImages(‘/images/menu_on.gif’)…;initLightbox()">
- It doesn't work if I click an image link before the page has finished loading.
- The script is activated only after the page has finished loading.
- The shadow overlay doesn't stretch to cover full browser window.
- Remove the default margin and padding from the body tag. Add
body{ margin: 0; padding: 0; }
to your stylesheet. - Can I insert links in the caption?
- Yes, but you need to convert quotes and greater and less than symbols into their html entity equivalents. For example:
<a href="images/image-4.jpg" rel="lightbox" title="<a href="link.html">my link</a>">Image</a>
- Can I display flash, video, or other content using the script?
- Sorry, photos only. For other content, google for Lightbox modifications or try an alternative script such as Cody Lindley's ThickBox.
- Can the script be called from an iframe?
- If you're using iframes, try the Lytebox modification which has better support.
- Can I use the script in a commercial project?
- Yes. It is licensed under the Creative Commons Attribution 2.5 License. A donation would be nice, hint hint.
As for proper attribution, all that is required is that you leave my name and link atop the lightbox javascript file. I do appreciate an html link, but it is not required.
CONTACT
For troubleshooting, feature requests, and general help, post a message in the Lightbox Forum. Make sure to include details on your browser, operating system, Lightbox version, and a link (or relevant code). I do not have time to personally respond to support emails, please use the forum.
To send me a non-support related note, email me. Thanks.
DONATE
If you're feeling generous, consider a donation. Any and all PayPal donations are sincerely appreciated. Thanks.
Etiquetas: 2A Java Script Manual
<< Inicio