2012-04-26 83 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="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
    <script type="text/javascript" src="fancybox/jquery.fancybox-1.3.4.pack.js"></script> 
    <script type="text/javascript" src="fancybox/jquery.easing-1.4.pack.js"></script> 
    <script type="text/javascript" src="fancybox/jquery.easing-1.4.pack.js"></script> 
    <script type="text/javascript" src="fancybox/jquery.mousewheel-3.0.4.pack.js"></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-media.js?v=1.0.0"></script> 
    <script type="text/javascript" src="/fancybox/source/helpers/jquery.fancybox-thumbs.js?v=2.0.6"></script> 
    <link rel="stylesheet" href="fancybox/source/helpers/jquery.fancybox-buttons.css?v=1.0.2" type="text/css" media="screen" /> 
    <link rel="stylesheet" href="fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" /> 
    <link rel="stylesheet" href="fancybox/source/helpers/jquery.fancybox-thumbs.css?v=2.0.6" type="text/css" media="screen" /> 

    <script type="text/javascript"> 

$(document).ready(function() { 
    $("a.fancybox").fancybox({ 

     'centerOnScroll':'true', 
     helpers : { 
     title : { 
      type : 'inside' 
     } 
    }, 


     'transitionIn':'elastic', 
     'transitionOut':'elastic', 
     'speedIn':600, 
     'speedOut': 200, 
     'overlayShow':false 
    }); 

}); 


</script> 

</head> 
<body style="font-family: Calibri; color: #505050; font-size: 9px; border-bottom-width: thin; margin-top: 5px; margin-left: 100px; margin-right: 100px; margin-bottom: -10px; float: left; position: absolute;"> 
<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"> 

        <?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" href="<?php echo $source; ?>"><img src="<?php echo $thumbnail; ?>" alt="<?php echo $name; ?>"/></a><?php endfor; ?> 
    </form> 
</body> 
</html> 

我遇到的問題是,我不能創建標題的圖像裏面,或者實際上其他任何地方,除了在「懸停」,這似乎是默認設置。我嘗試了各種不同的方式來嘗試並使其發揮作用。

$(document).ready(function() { 
    $("a.fancybox").fancybox({ 

     'centerOnScroll':'true', 
     'titleShow':'true', 
     'titlePosition':'inside', 
     'transitionIn':'elastic', 
     'transitionOut':'elastic', 
     'speedIn':600, 
     'speedOut': 200, 
     'overlayShow':false 
    }); 

}); 

$(document).ready(function() { 
     $("fancybox").fancybox({ 

      'centerOnScroll':'true', 
      'titleShow':'true', 
      'titlePosition':'inside', 
      'transitionIn':'elastic', 
      'transitionOut':'elastic', 
      'speedIn':600, 
      'speedOut': 200, 
      'overlayShow':false 
     }); 

    }); 

我試着添加和刪除',刪除空格,均無功而返。我只是想知道是否有人可以看看這個,讓我知道我要去哪裏錯了。

非常感謝和問候

回答

3

在這一行:

<a class="fancybox" rel="allimages" href="<?php echo $source; ?>"><img src="<?php echo $thumbnail; ?>" alt="<?php echo $name; ?>"/></a><?php endfor; ?> 

嘗試將a,而不是imgalt標籤內的title屬性。因此,它變成了:

<a class="fancybox" rel="allimages" title="<?php echo $name; ?>" href="<?php echo $source; ?>"><img src="<?php echo $thumbnail; ?>" /></a><?php endfor; ?> 
+0

@tomhallam嗨。太好了,非常感謝你的幫助。親切的問候 – IRHM 2012-04-26 17:27:40

+0

沒問題我的好人!樂意效勞。 – freshnode 2012-04-26 17:28:20

0

如果添加標題元素的定位標記不工作,你可以強制標題在你的fancybox設置

$(document).ready(function() { 
    $("fancybox").fancybox({ 
    'title'   : 'yourtitle' 
    'centerOnScroll' : 'true', 
    'titleShow'  : 'true', 
    'titlePosition' : 'inside', 
    'transitionIn' : 'elastic', 
    'transitionOut' : 'elastic', 
    'speedIn'  : 600, 
    'speedOut'  : 200, 
    'overlayShow' : false 
    }); 
});