0

我已经能够让 Fancybox 2 加载图像而没有任何问题。下面的代码让我可以点击图片barcode.gif(

<?php require_once('common/inc/default.php'); ?>
<!DOCTYPE html>
<head>
    <link rel="stylesheet" type="text/css" href="common/css/default.css" />
    <link rel="stylesheet" type="text/css" href="common/css/typography.css" />
    <link href='http://fonts.googleapis.com/css?family=Droid+Sans|Lobster' rel='stylesheet' type='text/css'>
    <!-- Add jQuery library -->
    <script type="text/javascript" src="common/js/lib/jquery-1.8.2.min.js"></script>

    <!-- Add fancyBox main JS and CSS files -->
    <script type="text/javascript" src="common/js/source/jquery.fancybox.js?v=2.1.3"></script>
    <link rel="stylesheet" type="text/css" href="common/js/source/jquery.fancybox.css?v=2.1.2" media="screen" />

    <link rel="stylesheet" type="text/css" href="common/js/source/helpers/jquery.fancybox-buttons.css?v=1.0.5" />
    <script type="text/javascript" src="common/js/source/helpers/jquery.fancybox-buttons.js?v=1.0.5"></script>

    <script type="text/javascript">
        $(document).ready(function() {
            $("a#single_image").fancybox();
        })
    </script>

</head>
<body>
    <div id="wrapper">
        <header>
            <div class="mast">Mighty Wash</div>
            <div class="navigation">
                <?=build_navigation();?>
            </div>
        </header>
        <section id="main">
            <a id="single_image" href="/common/img/barcode.gif"><img src="common/img/barcode.gif" /></a>
        </section>
        <footer>
        </footer>
    </div>
</body>
</html>

但是,当我尝试将谷歌地图嵌入 iframe 时,我什么也得不到。它只是导航到一个巨大的谷歌地图:

<?php require_once('common/inc/default.php'); ?>
    <!DOCTYPE html>
    <head>
    <link rel="stylesheet" type="text/css" href="common/css/default.css" />
    <link rel="stylesheet" type="text/css" href="common/css/typography.css" />
    <link href='http://fonts.googleapis.com/css?family=Droid+Sans|Lobster' rel='stylesheet' type='text/css'>
    <!-- Add jQuery library -->
    <script type="text/javascript" src="common/js/lib/jquery-1.8.2.min.js"></script>

    <!-- Add fancyBox main JS and CSS files -->
    <script type="text/javascript" src="common/js/source/jquery.fancybox.js?v=2.1.3"></script>
    <link rel="stylesheet" type="text/css" href="common/js/source/jquery.fancybox.css?v=2.1.2" media="screen" />

    <link rel="stylesheet" type="text/css" href="common/js/source/helpers/jquery.fancybox-buttons.css?v=1.0.5" />
    <script type="text/javascript" src="common/js/source/helpers/jquery.fancybox-buttons.js?v=1.0.5"></script>

    <script type="text/javascript">
        $(document).ready(function() {
            $("a.iframe").fancybox();
        })
    </script>

</head>
<body>
    <div id="wrapper">
        <header>
            <div class="mast">Mighty Wash</div>
            <div class="navigation">
                <?=build_navigation();?>
            </div>
        </header>
        <section id="main">
            <a class="iframe" href="http://maps.google.com/?output=embed&f=q&source=s_q&hl=en&geocode=&q=London+Eye,+County+Hall,+Westminster+Bridge+Road,+London,+United+Kingdom&hl=lv&ll=51.504155,-0.117749&spn=0.00571,0.016512&sll=56.879635,24.603189&sspn=10.280244,33.815918&vpsrc=6&hq=London+Eye&radius=15000&t=h&z=17">Google maps (iframe)</a>
        </section>
        <footer>
        </footer>
    </div>
</body>
</html>

有任何想法吗?

4

1 回答 1

1

我在这里整理了一个简单的例子

唯一真正的区别是在你的eg上使用“ fancybox ”和“ fancybox.iframe ”类<a>

<a class="fancybox fancybox.iframe" href="https://maps.google.com/?output=embed&f=q&source=s_q&geocode=&q=London+Eye,+County+Hall,+Westminster+Bridge+Road,+London,+United+Kingdom&hl=lv&ll=51.504155,-0.117749&spn=0.00571,0.016512&sll=56.879635,24.603189&sspn=10.280244,33.815918&vpsrc=6&hq=London+Eye&radius=15000&t=h&z=17">Google Map</a> 

然后将您的 fancybox 调用调整为:$(".fancybox").fancybox();相应地。

只是在那个 JSFiddle 中玩,如果我删除“fancybox.iframe ”类,我会遇到同样的问题。我没有深入研究 Fancybox 代码,但我的第一个假设是它绑定到该特定类,并阻止默认操作。

于 2012-12-15T22:08:29.827 回答