我有一个厚厚的盒子,可以在iframe中打开一个url。最初,当厚盒加载时,我隐藏了一个div。稍后,通过链接的单击函数,div将变得可见。现在,我已经将加厚框设置为初始iframe内容的高度,以使空白最小。因此,当显示隐藏的div时,就会出现带有滚动条的厚框。
我能在点击链接时动态地增加加厚框的高度吗?这样就可以避免滚动条了?
我已经在thickbox.js文件中手动设置了加厚框的高度。我不传递高度和宽度参数。
TB_WIDTH = (params['width']*1) + 30 || 980; //width need not change
TB_HEIGHT = (params['height']*1) + 40 || 650;//need to change this to 1150 on clicking a link编辑
//Parent page
<a href="thickbox.html" id="lightboxLink" class="thickbox"></a> //Opens the thickbox
//Thickbox content
<div id="main-content">
//Content
</div>
<div id="other-content" class="hidden"> //hidden div
// Div content
</div>
<a id="more-info" href="#" >Show more information</a>
//js
$('#more-info').click(function() {
$('#other-content').show();
}); 发布于 2011-05-02 17:23:41
厚盒应该有一个包含的div包在iframe周围。在我看过的示例中,这个div有一个TB_Window ID。假设您的代码是相同的,您可以在jQuery代码中执行如下操作:
$('#more-info').click(function() {
$('#other-content').show();
var thickboxHeight = parseInt($('#TB_Window').css('height'));
var otherHeight = parseInt($('#other-content').css('height'));
$('#TB_Window').css('height', (thickboxHeight + otherHeight).toString() + 'px');
});或者,如果您只需要将其设置为1150‘s(只需在代码注释中看到这一点),就会简单得多:
$('#more-info').click(function() {
$('#other-content').show();
$('#TB_Window').css('height', '1150px');
});https://stackoverflow.com/questions/5854380
复制相似问题