Fancybox 1.3.4 无法工作
嘿,我正在尝试实现 fancybox 1.3.4,但我无法让它工作 这是我的代码:
<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.easing-1.3.pack.js"></script>
<script src="/fancybox/jquery.fancybox-1.3.4.pack.js" type="text/javascript"></script>
<script src="/fancybox/jquery.fancybox-1.3.4.js" type="text/javascript"></script>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="/fancybox/jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript">
$(document).ready(function() {
/* This is basic - uses default settings */
$(".image").fancybox();
/* Using custom settings */
$(".iframe").fancybox({
'hideOnContentClick': false
});
$("a[href$=.jpg],a[href$=.png],a[href$=.gif]").fancybox();
$(".youtube").click(function() {
$.fancybox({
'padding': 0,
'autoScale': false,
'transitionIn': 'none',
'transitionOut': 'none',
'title': this.title,
'width': 680,
'height': 495,
'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
'type': 'swf',
'swf': {
'wmode': 'transparent',
'allowfullscreen': 'true'
}
});
return false;
});
这是我想要 fancybox 打开的图像。目前它仅显示在新选项卡中。 我使用 firebug,我可以看到每个脚本和样式表都加载了。
<a class="image" href="http://localhost:2053/files/15-20/theme3/test%20Photo.jpg">test Photo</a>
Hey im trying to implement fancybox 1.3.4 and I just cant get it to work
Heres my code:
<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.easing-1.3.pack.js"></script>
<script src="/fancybox/jquery.fancybox-1.3.4.pack.js" type="text/javascript"></script>
<script src="/fancybox/jquery.fancybox-1.3.4.js" type="text/javascript"></script>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="/fancybox/jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript">
$(document).ready(function() {
/* This is basic - uses default settings */
$(".image").fancybox();
/* Using custom settings */
$(".iframe").fancybox({
'hideOnContentClick': false
});
$("a[href$=.jpg],a[href$=.png],a[href$=.gif]").fancybox();
$(".youtube").click(function() {
$.fancybox({
'padding': 0,
'autoScale': false,
'transitionIn': 'none',
'transitionOut': 'none',
'title': this.title,
'width': 680,
'height': 495,
'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
'type': 'swf',
'swf': {
'wmode': 'transparent',
'allowfullscreen': 'true'
}
});
return false;
});
This is the image I want fancybox to open. Presently it just shows up in a new tab.
I use firebug and I can see that every script and stylesheet loads.
<a class="image" href="http://localhost:2053/files/15-20/theme3/test%20Photo.jpg">test Photo</a>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我猜这只是一个剪切&粘贴错误,但我将说明明显的情况以防万一。你的 jquery 路径中有空格:
它应该是:
要 100% doubleplus 确保 jquery 已加载,请打开 Firebug 控制台并运行此代码片段:
它应该通过打印版本号来响应。
I'm guessing this was just a cut & paste error, but I'm going to state the obvious just in case. Your path to jquery has spaces in it:
It should be:
To be 100% doubleplus sure that jquery is loaded, open up the Firebug console and run this snippet:
It should respond by printing the version number.
看起来您的 document.ready 函数并未包含所有选择器语句。您还可能缺少结束脚本标记。
尝试将其添加到脚本的末尾:
完整脚本:
It looks like your document.ready function isn't enclosing all of your selector statements. You also might be missing the closing script tag.
Try adding this to the end of your script:
Full script:
您应该将 src 更改为
而不是此处的内容,
仔细阅读以注意两个示例的 src 属性的差异,
对所有 src 属性进行此更改,您应该可以开始了。
you should change the src to
instead of what you have here
read carefully to note the difference in the src attribute of the two samples,
make this change to all the src attributes and you should be good to go.