Javascript Fancybox 1.3.4就是不起作用
嘿,我正在尝试实现fancybox 1.3.4,但我就是不能让它工作 这是我的密码:Javascript Fancybox 1.3.4就是不起作用,javascript,jquery,css,fancybox,Javascript,Jquery,Css,Fancybox,嘿,我正在尝试实现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 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;
});
$(文档).ready(函数(){
/*这是基本设置-使用默认设置*/
$(“.image”).fancybox();
/*使用自定义设置*/
$(“.iframe”).fancybox({
“hideOnContentClick”:false
});
$(“a[href$=.jpg]、a[href$=.png]、a[href$=.gif]).fancybox();
$(“.youtube”)。单击(函数(){
$.fancybox({
“填充”:0,
“自动缩放”:false,
“transitionIn”:“无”,
“transitionOut”:“无”,
“title”:this.title,
“宽度”:680,
‘高度’:495,
'href':this.href.replace(新的RegExp(“watch\\?v=,“i”),'v/'),
“类型”:“swf”,
“swf”:{
'wmode':'transparent',
“allowfullscreen”:“true”
}
});
返回false;
});
这是我希望fancybox打开的图像。目前它只显示在一个新选项卡中。
我使用firebug,我可以看到每个脚本和样式表都会加载
<a class="image" href="http://localhost:2053/files/15-20/theme3/test%20Photo.jpg">test Photo</a>
您应该将src更改为
<script type="text/javascript" src="fancybox/jquery.easing-1.3.pack.js"></script>
而不是你这里的
<script type="text/javascript" src="/fancybox/jquery.easing-1.3.pack.js"></script>
仔细阅读,注意两个示例的src属性的差异,
对所有的src属性进行此更改,您应该可以开始了。我猜这只是一个剪切粘贴错误,但我将陈述一个明显的以防万一的问题。您到jquery的路径中有空格:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery /1.4/jquery.min.js"></script>
它应该通过打印版本号来响应。看起来您的document.ready函数没有包含所有选择器语句。您还可能缺少结束脚本标记 尝试将以下内容添加到脚本末尾:
});
</script>
});
完整脚本:
<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;
});
});
</script>
$(文档).ready(函数(){
/*这是基本设置-使用默认设置*/
$(“.image”).fancybox();
/*使用自定义设置*/
$(“.iframe”).fancybox({
“hideOnContentClick”:false
});
$(“a[href$=.jpg]、a[href$=.png]、a[href$=.gif]).fancybox();
$(“.youtube”)。单击(函数(){
$.fancybox({
“填充”:0,
“自动缩放”:false,
“transitionIn”:“无”,
“transitionOut”:“无”,
“title”:this.title,
“宽度”:680,
‘高度’:495,
'href':this.href.replace(新的RegExp(“watch\\?v=,“i”),'v/'),
“类型”:“swf”,
“swf”:{
'wmode':'transparent',
“allowfullscreen”:“true”
}
});
返回false;
});
});
});
</script>
<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;
});
});
</script>