---
title: "jQuery lightBox();"
author: "dragon0929"
date: "2010-06-22T12:28:42Z"
tags: []
categories: ["Web前端"]
slug: "jquery-lightbox"
draft: false
lastmod: "2010-06-22T12:28:42Z"
id: 696327
url: "https://dragon0929.iteye.com/blog/696327"
---

最近做图片显示时，发现了jQuery的lightBox()功能很强大，记录下来：

 

官方DEMO：

http://leandrovieira.com/projects/jquery/lightbox/

 

Sample:

 

&lt;%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %&gt;  
&lt;%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %&gt;

&lt;%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %&gt;  
&lt;%@ taglib uri="http://richfaces.org/rich" prefix="rich" %&gt;

&lt;link rel="stylesheet" type="text/css"  
      href="&lt;h:outputText value="#{request.contextPath}"/&gt;/css/jquery.lightbox.css"/&gt;  
&lt;script type="text/javascript" charset="utf-8"  
        src="&lt;h:outputText value="#{request.contextPath}"/&gt;/js/jquery.lightbox.min.js.jsp"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;  
    jQuery(function() {  
        reload();  
    });

    function reload() {  
        jQuery('.lightboximg').lightBox();  
    }  
&lt;/script&gt;  
&lt;h:panelGrid columns="2"&gt;  
    &lt;rich:dataGrid id="profilePhotoGrid"  
                   value="#{artistManageBean.profilePhotos}"  
                   var="photo" columns="4" elements="12"&gt;  
        &lt;f:facet name="header"&gt;  
            &lt;rich:datascroller align="left" oncomplete="reload();" renderIfSinglePage="false"/&gt;  
        &lt;/f:facet&gt;  
        &lt;h:panelGrid&gt;  
            &lt;f:verbatim&gt;  
                &lt;h:panelGroup&gt;  
                    &lt;a4j:commandLink id="remove" ajaxSingle="true"  
                                     reRender="artist:profilePhotoGrid"  
                                     action="#{artistManageBean.doRemoveProfilePhoto}"  
                                     title="Remove the photo"  
                                     styleClass="control-thumb-img"  
                                     oncomplete="fixBrokenImages();"  
                                     eventsQueue="remQueue"&gt;  
                        &lt;h:graphicImage id="remimg" url="/images/icons/delete.png"/&gt;  
                    &lt;/a4j:commandLink&gt;  
                    &lt;a class="lightboximg" href="&lt;h:outputText value="#{request.contextPath}/photo/large/#{photo.name.fullPath}"/&gt;"&gt;  
                         &lt;h:graphicImage id="img" url="/photo/thumbnail/#{photo.name.fullPath}"  
                                         styleClass="thumbnailArtistImage"/&gt;  
                    &lt;/a&gt;  
                &lt;/h:panelGroup&gt;  
            &lt;/f:verbatim&gt;  
        &lt;/h:panelGrid&gt;  
    &lt;/rich:dataGrid&gt;  
    &lt;h:panelGroup&gt;  
         &lt;h:graphicImage id="def"  
            url="/photo/normal/#{artistManageBean.defaultPhoto.name.fullPath}"  
            style="opacity:0.85; border: 1px solid rgb(237, 237, 237); padding: 1px;"/&gt;  
        &lt;br/&gt;  
         
        &lt;div style="margin-bottom:5px;"&gt;  
           &lt;strong&gt;&lt;h:outputText value="Upload new Photo: " /&gt;&lt;/strong&gt;  
       &lt;/div&gt;  
       &lt;div style="background-color: #ffffff; text-align: center; width: 280px;"&gt;  
           &lt;rich:fileUpload fileUploadListener="#{artistManageBean.profilePhotoUploadListener}"  
                            id="profilePhotoUpload" immediateUpload="true"  
                            listWidth="280" listHeight="150" autoclear="true"  
                            acceptedTypes="jpg, gif, png"&gt;  
               &lt;a4j:support event="onuploadcomplete" reRender="artist:profilePhotoGrid"  
                            oncomplete="fixBrokenImages();"/&gt;  
           &lt;/rich:fileUpload&gt;  
       &lt;/div&gt;  
       &lt;div class="note"&gt;&lt;b&gt;Images types allowed: &lt;/b&gt;JPG, GIF, PNG&lt;/div&gt;  
    &lt;/h:panelGroup&gt;  
    
&lt;/h:panelGrid&gt;