Fancybox:iframe不起作用 [英] Fancybox: iframe doesn't work
问题描述
非常简单的test.html页面:
Very simple test.html page:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="fancybox/jquery.fancybox.pack.js"></script>
<link rel="stylesheet" href="fancybox/jquery.fancybox.css" type="text/css" media="screen"/>
<script type="text/javascript">
$(document).ready(function () {
/* This is basic - uses default settings */
$("a.iframe").fancybox();
});
</script>
</head>
<body>
<a class="iframe" href="http://www.google.be/">This goes to iframe</a>
</body>
</html>
但是,fancybox仍然无法使用...对js文件和css的引用是正确的. JQuery正常运行.但是单击链接只是一个普通的链接.即:我重定向到google.be.仅供参考:不仅仅与Google有关,而且与我在其中输入的每个URL有关.我在这里想念什么?
Yet, fancybox just won't work... The references to the js file and css are correct. JQuery functions normally. But clicking the link acts just a normal link. Ie: I get redirect to google.be. FYI: It's not just with google, it's with every single URL I put there. What am I missing here?
推荐答案
我成功将锚点上的 class 更改为fancybox fancybox.iframe
.
I had success changing the class on the anchor to fancybox fancybox.iframe
.
<a class="fancybox fancybox.iframe" href="http://www.google.be/">This goes to iframe</a>
<script type="text/javascript">
$(document).ready(function() {
$('a.fancybox').fancybox();
});
</script>
不知道为什么会这样,但是对我有用.
No idea why this is the case but it worked for me.
编辑:还需要更新到jQuery的最新版本
Edit: also need to update to a recent version of jQuery
这篇关于Fancybox:iframe不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!