0

我一直在尝试让 SWF 文件在 FancyBox 中工作。FancyBox 本身工作正常,我遇到的唯一问题是使用 SWF 文件时。

这是 HTML 部分:

<div id="box-6" class="box"> <a class="various" href="content/test.swf">swf</a>
    <img id="image-6" src="/image_28.png"/>
    <span class="caption scale-caption">
    <h3> test <br><em><font size="1"> test </em></font></h3>
        <p> test </p>
  </span>

这是 JS 部分,位于我脚本的最顶部:

 <script type="text/javascript">

$(document).ready(function() {

$(".various").fancybox({
    maxWidth    : 800,
    maxHeight   : 600,
    fitToView   : false,
    width       : '70%',
    height      : '70%',
    autoSize    : false,
    closeClick  : false,
    openEffect  : 'none',
    closeEffect : 'none'
});


$('#single_3').fancybox({
    openEffect : 'elastic',
    closeEffect : 'elastic',
    helpers : {
        title : {
            type : 'outside'
        }
    }
});
});

当我单击图像时,没有任何反应。

我也试着这样说,仍然没有任何反应:

<a id="single_3" <a class="various" href="content/test.swf" title=" test ">swf</a>
<img id="image-6" src="/image_28.png"/>
<span class="caption scale-caption">
<h3> test <br><em><font size="1"> test </em></font></h3>
    <p> test </p>

我不知道我应该做什么。

4

1 回答 1

0

您只需要将fancybox 绑定到一个选择器,无论是您的ID 还是您的类(如果计划将fancybox 绑定到多个元素,那么请改用类)所以

有这个 html :

<a title="Lorem ipsum" class="various" href="content/test.swf">Open SWF</a>

...确保swf文件的路径正确

然后,使用单个脚本并在其中设置所有 API 选项:

jQuery(document).ready(function ($) {
    $(".various").fancybox({
        // all your API options here, whatever they are
        maxWidth: 800,
        maxHeight: 600,
        fitToView: false,
        width: '70%',
        height: '70%',
        autoSize: false,
        closeClick: false,
        openEffect: 'none',
        closeEffect: 'none',
        helpers: {
            title: {
                type: 'outside'
            }
        },
        type: "swf" // you need to say is a swf content
    }); // fancybox
}); // ready

请注意,我们添加了该选项type: "swf",因此 fancybox 将知道type它需要处理的内容。

有关工作示例,请参阅JSFIDDLE 。

于 2013-06-10T15:46:27.263 回答