0

...对不起,但我有一个没有解决方案的类似问题:

我使用此代码从 iframe 内部打开一个花式框。这里是头部:

<!-- Add jQuery library -->
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

<!-- Add fancyBox -->
<link rel="stylesheet" href="fancybox/source/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" />
<script type="text/javascript" src="fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

我用这个代码附加fancyBox:

<!-- Attach fancyBox when the document is loaded.  -->
<script>
/* <![CDATA[ */
$(document).ready(function() {
$('.fancybox').click(function(e){
    e.preventDefault();
    parent.$.fancybox({
        href: this.href,
        width: 1280,
        height: 1000,
        padding: 10,
        type: 'iframe',
        scrolling : 'no',
        openEffect  : 'fade',
        closeEffect : 'elastic',
        helpers: {
            title : { position : 'bottom', type : 'float' },
            overlay: { css : { 'background' : 'rgba(0,0,0,0.8)' }
             }, // overlay
        } // helpers
    }); // fancybox
}); // click
}); // ready
/* ]]> */
</script>    

正文部分的链接如下:

    <a title='Sample title' class='fancybox' href='1_BIG.php'>
<img src="image.jpg" width="100" height="100">
</a>

但没有显示标题。:(

当我将以下行写入附加代码时,标题显示出来,但只是静态的,这无济于事:

   title : 'just a static title',

有人可以帮我吗?

4

1 回答 1

0

由于您使用手动方法触发 fancybox ,$('.fancybox').click()因此title不会拾取属性,因此您需要强制它添加 API 选项

title: this.title

JSFIDDLE

注意:标题type: 'float'是默认的,总是在花式框的底部,所以定位它没有效果

helpers: {
    title: {
        // position: 'bottom', // <== useless if using "float"
        type: 'float' // this is default so you don't have to set it unless is different
    },
    ...
于 2013-10-15T22:34:10.437 回答