2012-04-28 63 views
0

我不知道是否有人可以提供幫助。fancyBox圖片號碼

我創建使用的fancybox圖片庫,如下面的代碼:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title>Gallery</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <script type="text/javascript" src="fancybox/lib/jquery-1.7.2.min.js"></script> 
    <script type="text/javascript" src="fancybox/source/jquery.fancybox.js?v=2.0.6"></script> 
    <script type="text/javascript" src="fancybox/source/helpers/jquery.fancybox-buttons.js?v=1.0.2"></script> 
    <script type="text/javascript" src="fancybox/source/helpers/jquery.fancybox-thumbs.js?v=1.0.2"></script> 
    <script type="text/javascript" src="fancybox/source/helpers/jquery.fancybox-media.js?v=1.0.0"></script> 
    <link rel="stylesheet" type="text/css" href="fancybox/source/helpers/jquery.fancybox-thumbs.css?v=1.0.2" /> 
    <link rel="stylesheet" type="text/css" href="fancybox/source/helpers/jquery.fancybox-buttons.css?v=1.0.2" /> 
    <link rel="stylesheet" type="text/css" href="fancybox/source/jquery.fancybox.css?v=2.0.6" media="screen" /> 


    <script type="text/javascript"> 

      $('.fancybox').fancybox({ 
       openEffect : 'elastic', 
       closeEffect : 'elastic', 

       padding : 20, 
       fitToView : true, 

       prevEffect : 'none', 
       nextEffect : 'none', 

       closeBtn : false, 
       arrows : false, 

       helpers : { 
        title : { 
         type : 'inside' 
        }, 
        buttons : {} 
       }, 

       afterLoad : function() { 
        this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : ''); 
       } 
      }); 


</script> 
    <style type="text/css"> 
<!-- 
.style1 { 
    font-size: 14px; 
    margin-top: 5px; 
    margin-right: 110px; 
} 
--> 
    </style> 
</head> 
<body style="font-family: Calibri; color: #505050; margin-left: 240px; float:left;"/> 
<div align="right" class="style1"> <a href = "javascript:document.gallery.submit()"/> Add Images <a/> &larr; View Uploaded Images </div> 
    <form id="gallery" name="gallery" class="page" action="index.php" method="post" style="margin-left: -120px; margin-right: 50px;"> 

    <p> 
     <?php for ($i = 0; $i < $descriptions->documentElement->childNodes->length; $i++) : 
          $xmlFile = $descriptions->documentElement->childNodes->item($i); 
          $name = htmlentities($xmlFile->getAttribute('originalname'), ENT_COMPAT, 'UTF-8'); 
          $description = htmlentities($xmlFile->getAttribute('description'), ENT_COMPAT, 'UTF-8'); 
          $source = $galleryPath . rawurlencode($xmlFile->getAttribute('source')); 
          $thumbnail = $thumbnailsPath . rawurlencode($xmlFile->getAttribute('thumbnail')); 
        ?> 
     <a class="fancybox" rel="allimages" title="<?php echo $name; ?>" href="<?php echo $source; ?>"><img src="<?php echo $thumbnail; ?>"alt="<?php echo $description; ?>" /></a> 
     <?php endfor; ?> 
    </p> 
</form> 
</body> 
</html> 

工作一切良好,除了頁碼即「形象的數...」內容只出現第一張圖片。

我已經從'fancyapps'網站直接使用了這段代碼,所以我有點不確定錯誤在哪裏,因爲它們看起來都一樣。

我只是想知道是否有人可以看看這個請讓我知道我哪裏出了問題。

非常感謝和問候

+0

一個自包含jsFiddle的例子在這裏會非常有幫助。 – 2012-04-28 11:18:09

+0

嗨,是的,我知道,我真的很抱歉,我沒有提供這個。說實話,我不知道如何使用jsFiddle,而且我不想把這個帖子弄得亂七八糟。我現在看看看看我能放在一起。我也遇到的問題是腳本在PHP上運行,我不確定PHP是否可以在jsFiddle中使用。爲了幫助更多,我修改了我原來的帖子並添加了完整頁面腳本。親切的問候 – IRHM 2012-04-28 12:24:59

+0

你試過在'$(document).ready(function(){// fancybox script here})中包裝你的fancybox自定義腳本嗎? – JFK 2012-04-28 18:43:40

回答

1

使用「的fancybox」的新verison這已得到解決和圖像編號工作正常。