问题
This my code:
<a href="url" class="fancybox">Text</a>
jQuery(document).ready(function() {
jQuery(".fancybox").fancybox({
'overlayShow': true,
'hideOnContentClick': false
});
});
The box is displayed, the content is loaded but in the error console of chrome "Uncaught TypeError: Cannot call method 'width' of undefined".
The box can be closed but then it is not possible to open it again.
I am using FB 1.3.4 and jQuery 1.5.1.
回答1:
Ive had this same problem before and the cause was that I was loading the fancybox.1.3.4.js file inside of the file that was getting loaded by fancybox in the first place.
If you are doing this as well, it will be the problem. Otherwise I do not know.
回答2:
Problem is caused by your code where you did not mention of using iframe.
You will have to declare like this:
$('a[rel^=iframe_group]').fancybox({
'autoDimensions' : false,
'autoScale' : false,
'width' : '50%',
'height' : '80%',
'transitionIn' : 'none',
'transitionOut' : 'none',
**'type' : 'iframe'**
});
来源:https://stackoverflow.com/questions/6535803/jquery-fancybox-produces-a-loop-of-errors-in-chrome-using-ajax