Fancybox脚本无法正常工作

时间:2011-03-07 08:55:23

标签: javascript jquery html css fancybox

我多次使用过Fancybox,但从未遇到过这个问题。我在标题中包含了jQuery和Fancybox文件,将第一个订单按钮链接到页面以在Fancybox中打开iframe。但是我似乎无法让它工作。它没有打开iframe,而是直接进入我试图在Fancybox iframe中打开的页面。

有人可以指出我星期一早上做出的任何令人眼花缭乱的明显错误吗?

测试服务器可以在这里找到:

http://www.designti.me/testing/flipstick/original.php

4 个答案:

答案 0 :(得分:3)

错误消息为:Uncaught TypeError: Object #<an Object> has no method 'fancybox'

这意味着fancybox尚未加载。仔细查看您的来源,我们看到<script type="text/x-ecmascript" src="js/fancybox/jquery.fancybox-1.3.4.pack.js"></script>您可以看到使用x-ecmascript而不是javascript。改变这一点,你应该没事。

答案 1 :(得分:1)

您没有将代码放入ready处理程序:

$(function() {                   // <-- you need this
    $("a.iframe").fancybox({ 
        //...
    });
});                              // <-- and this

答案 2 :(得分:0)

也许把它放在document.ready中?

$(document).ready(function() {
    $("a.iframe").fancybox({
         'width' : '75%',
         'height' : '75%',
         'autoScale' : false,
         'transitionIn' : 'none',
         'transitionOut' : 'none',
         'type' : 'iframe'
    });       
});

答案 3 :(得分:0)

使用此:

jQuery(document).ready(function(){

      jQuery("a.iframe").fancybox({
        'type' : 'iframe',  //<--missing comma here
        'width':750,
        'height':500  //<-- removed last comma here
    });

});