Fancybox不起作用

时间:2014-06-17 18:26:17

标签: javascript jquery html fancybox

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="../../fancybox/source/jquery.fancybox.pack.js"></script>
<link rel="stylesheet" href="../../fancybox/source/jquery.fancybox.css" type="text/css" media="screen"/>
</head>

<body>
<a id = "single_image" href = "images/decoration/bottom4.jpg"><img src="images/decoration/bottom4.jpg" alt=""/></a>
<script type="text/javascript">
    $(document).ready(function(){
        $("a#single_image").fancybox();
    });
</script>
</body>
</html>

我正在尝试让fancybox显示图像,但它只是在外部保持链接到图像。这是我的代码的缩短版本,但它仍然无法正常工作。通常,这个问题是由加载jQuery两次引起的,但这似乎并非如此。

1 个答案:

答案 0 :(得分:0)

请务必使用此处提供的说明http://fancyapps.com/fancybox/

工作代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<link rel="stylesheet" href="../../fancybox/source/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" />
<script type="text/javascript" src="../../fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

</head>

<body>
<a class="fancybox" rel="group" href="images/decoration/bottom4.jpg"><img src="images/decoration/bottom4.jpg" alt="" /></a>

<script type="text/javascript">
$(document).ready(function() {
$(".fancybox").fancybox();
});
</script>
</body>
</html>