【问题标题】:can the thickbox height be increased on clicking a link in the thickbox?点击thickbox中的链接可以增加thickbox的高度吗?
【发布时间】:2011-05-02 07:06:09
【问题描述】:

我有一个在 iframe 中打开 url 的厚框。最初,当厚盒加载时,我隐藏了一个 div。稍后,通过链接的点击功能,使 div 可见。现在我将厚框设置为初始 iframe 内容的高度,这样空白区域就最小了。所以当隐藏的 div 显示出来时,thickbox 就会出现滚动条。

我可以在点击链接时动态增加厚框的高度吗?这样可以避免滚动条吗?

我在thickbox.js 文件中手动设置了thickbox 的高度。我没有传递高度和宽度参数。

 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();
});  

【问题讨论】:

  • 你能告诉我们你现有的代码吗?
  • 我更多地指的是链接周围的 html,单击该链接以触发使 div 可见的 JS 函数,以及该函数和任何其他相关的 JS。

标签: jquery thickbox


【解决方案1】:

thickbox 应该有一个包含在 iframe 周围的 div。在我查看的示例中,此 div 的 ID 为 TB_Window。假设您的相同,您可以在 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 像素(刚刚在您的代码 cmets 中看到),它会简单得多:

$('#more-info').click(function() {   
     $('#other-content').show();
     $('#TB_Window').css('height', '1150px');
});

【讨论】:

    猜你喜欢
    • 2013-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多