A simple Lightbox for jQuery
Sanebox is a jQuery plugin for displaying images and videos in an on-page lightbox. Using Sanebox, you can add clickable thumbnails of images or videos on your site which will open the media without leaving the page. Some of Sanebox's features:
The web is a sprawling, monstrous entity. Developing re-usable JavaScript code, especially code meant to interact with new features like HTML 5 video, is tricky. I tested Sanebox under several browsers at my disposal, even tore out my hair over a few Internet Explorer that took a while to resolve, but I obviously cannot guarantee that it will always work. Assuming that you have it set up correctly, it should work under the following browsers. Please let me know if you have used it on another browser or earlier version and it works.
<head>
tag:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="sanebox/jquery.sanebox.min.js"></script>
You do not need to worry about including the css file or other helper scripts; Sanebox knows
how to include the files it needs.
<p class="gallery">
<a class="lightbox" href="images/safeco.jpg" title="One Example">
<img src="images/safeco_th.jpg" alt="This is a caption. They're not necessary." />
</a>
<a class="lightbox" href="images/rocks.jpg" title="Another Examples. Titles also aren't necessary.">
<img src="images/rocks_th.jpg" alt="A different item, a different caption." />
</a>
<a class="lightbox" href="spaceroids.flv" title="One Example">
<img src="spaceroids_flv_th.jpg" alt="This is a Flash video, but Sanebox can also display HTML 5 (H.264/Theora/VP8) video." />
</a>
</p>
Make sure that the referenced images actually exist! You can copy the ones from this site
if you don't have any images immediately avialable for experimenting.
<head>
tag, right after the script
tag that includes Sanebox:
<script type="text/javascript">
$(document).ready(function () {
$(".lightbox").sanebox({
group : 'default'
});
});
</script>
Sanebox itself is available under a Creative Commons license. You are free to modify and share it, even for commercial purposes, as long as you attribute the author (me) and you make the code available for others to modify.
Some of the components used by Sanebox are available under different licenses. Specifically,
Dave Short — dave at daveshort dot org