Reputation: 6027
I have been ble to get Fancybox 2 to load images without any problems. The following code allows me to click on the image (barcode.gif
) and have it open in a fancybox without any problems (I have heavily omitted page content so that it is easier to see the image):
<?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>
However, when I try to embed a google map into an iframe, I get nothing. It just navigates to a giant google map:
<?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>
Any Ideas?
Upvotes: 0
Views: 1144
Reputation: 536
I put together a simple example of this working HERE
The only real difference is using the classes "fancybox" and "fancybox.iframe" on your <a>
e.g.
<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>
And then adjusting your fancybox call to: $(".fancybox").fancybox();
accordingly.
Just playing in that JSFiddle, if I remove the "fancybox.iframe" class, I get the same issue you are seeing. I have not dug through the Fancybox code, but my first assumption would be it is binding to that specific class, and prevent the default action.
Upvotes: 1