最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Fancybox script not working - Stack Overflow

matteradmin6PV0评论

I have used Fancybox on multiple occasions and never run into this problem. I have included both jQuery and Fancybox files in the header, linked up the first order button the the page to open up an iframe in a Fancybox. However I cant seem to get it to work at all. It doesn't open an iframe and instead goes straight to the page I was trying to open inside the Fancybox iframe.

Can somebody point out whatever blindingly obvious mistake I've made this horrible Monday morn?

Testing server can be found here:

.php

I have used Fancybox on multiple occasions and never run into this problem. I have included both jQuery and Fancybox files in the header, linked up the first order button the the page to open up an iframe in a Fancybox. However I cant seem to get it to work at all. It doesn't open an iframe and instead goes straight to the page I was trying to open inside the Fancybox iframe.

Can somebody point out whatever blindingly obvious mistake I've made this horrible Monday morn?

Testing server can be found here:

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

Share Improve this question asked Mar 7, 2011 at 8:55 Alex SadlerAlex Sadler 4332 gold badges8 silver badges22 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 3

The error message is: Uncaught TypeError: Object #<an Object> has no method 'fancybox'

Which implies that fancybox hasn't loaded. Taking a close look at your source we see <script type="text/x-ecmascript" src="js/fancybox/jquery.fancybox-1.3.4.pack.js"></script> which you can see uses x-ecmascript rather than javascript. Change that and you should be fine.

You didn't put your code into the ready handler:

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

Maybe to put it in document.ready?

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

Use this:

jQuery(document).ready(function() {

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

});

Post a comment

comment list (0)

  1. No comments so far