问题
I can't get fancybox to open my links in iframe. My code below. Thanks!
<link href="./fancybox/jquery.fancybox-1.3.4.css" type="text/css" rel="stylesheet"/>
<script src="_js/jquery-1.7.2.min.js"></script>
<script src="fancybox/jquery.fancybox-1.3.4.js"></script>
<script>
$(document).ready(function() {
$('.iframe').fancybox({
'width': '85%',
'height': '75%',
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe'
}); // end fancybox
}); // end ready
</script>
And the link I'm trying to open from my page
<a href="http://www.nytimes.com/2010/07/18/books/review/Boyd-t.html" class="iframe">
<div class="linkcontainer"><h1>Review</h1></div></a>
回答1:
There is nothing wrong with your code but the issue has nothing to do with fancybox.
Most probably that page is using X-Frame-Options response header
to disallow the page to be opened within an iframe
(the case with fancybox, which uses the html iframe
tag)
Check this link for further information https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header
Your code will work just fine with any other page from the same domain or not protected against clickJacking though.
来源:https://stackoverflow.com/questions/11278770/links-not-showing-in-fancybox-iframe