我有这个功能“resizePortfolio”,我稍后通过“resizePortfolio();”来调用它。但控制台说“Uncaught ReferenceError:resizePortfolio未定义。”这是为了使我的幻灯片响应,但由于某种原因,它给出了一个错误,我不明白为什么......
我真的很感谢你的帮助。
function resizePortfolio() {
slideshowTitleHeight = $('.slideshow_title').height() + 20;
slideshowControlsHeight = $('.slideshow_controls').height() + 20;
if (showFullScreen == true) {
_w = $('#wrapper').width() - (slideshowPaddingLeft + slideshowPaddingRight); // width for the slideshow item
} else {
_w = $('#wrapper').width() - menuWidth - (slideshowPaddingLeft + slideshowPaddingRight); // width for the slideshow item
}
_h = $('#content').height() - (slideshowPaddingTop + slideshowPaddingBottom + slideshowControlsHeight + slideshowTitleHeight); // height for the slideshow item
$('.slideshow, .slideshow li, .slideshow li, .slideshow li table, .slideshow li table td').css({'width':_w, 'height':_h});
$('.slideshow li table td img').css({'max-height':_h,'max-width':_w});
$(slideshowContainer).children('li').each(function() {
_imgH = $(this).find('img').height(); // height for the slideshow image
_imgW = $(this).find('img').width(); // width for the slideshow image
if ($(this).hasClass('assettype2')) {
hasVideo = true;
}
// position for the share overlay
if (hasVideo == true) {
$(slideshowShareContainer, this).height(_h).width(_w);
$(slideshowShareContainer, this).children('div').height(_h).width(_w);
$('.slideshow_share_links', this).width(_w/2);
var margin = _w/2;
var marginTop = (_h/2) - (_h/2);
$(slideshowShareContainer, this).css({'marginLeft': -margin});
} else {
$(slideshowShareContainer, this).height(_imgH).width(_imgW+1);
$(slideshowShareContainer, this).children('div').height(_imgH).width(_imgW);
$('.slideshow_share_links', this).width(_imgW/2);
$('.slideshow_share_links.blog', this).width(_imgW);
var margin = _imgW/2;
var marginTop = (_h/2) - (_imgH/2);
$(slideshowShareContainer, this).css({'marginLeft': -margin});
}
});
}
答案 0 :(得分:0)
确保通话:
$(window).on("resize", resizePortfolio);
位于$(document).ready(function() {...})
主体内部,因为函数名称的范围就是该函数。