0

我想知道是否有人可以提供帮助。

我对此有点陌生,所以我确信这将是一个基本问题,但请多多包涵。

我正在使用下面的脚本来创建一个带有 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> 

我遇到的问题是我无法在图像内创建标题,或者实际上除了“悬停”之外的任何其他地方,这似乎是默认设置。我已经尝试了各种不同的方法来尝试让它发挥作用。

IE

$(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
        });

    });

我试过添加和删除',删除空格,都没有成功。我只是想知道是否有人可以看看这个并让我知道我哪里出错了。

非常感谢和问候

4

2 回答 2

3

在这一行:

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

尝试在 中设置title属性a,而不是altimg. 所以它变成:

<a class="fancybox" rel="allimages" title="<?php echo $name; ?>" href="<?php echo $source; ?>"><img src="<?php echo $thumbnail; ?>" /></a><?php endfor; ?> 
于 2012-04-26T17:21:20.737 回答
0

如果将标题元素添加到您的锚标记不起作用,您可以在您的幻想框设置中强制标题

$(document).ready(function() { 
  $("fancybox").fancybox({
    'title'          : 'yourtitle'
    'centerOnScroll' : 'true',
    'titleShow'      : 'true',
    'titlePosition'  : 'inside',
    'transitionIn'   : 'elastic',
    'transitionOut'  : 'elastic',
    'speedIn'        : 600, 
    'speedOut'       : 200,
    'overlayShow'    : false
  });
});
于 2013-06-27T09:31:27.977 回答