我正在制定一个日历/时间表,该日历/时间表需要休息以跨越包含事件的整个高度。以下代码在FF/Chrome和IE中运行良好。在Firefox中通过iFrame加载内容时会出现问题,因为高度总是设置为零。只有在重新加载iFrame时,页面才会正确显示。
这是演示
$(window).load(function () {
$(".event").each(function () {
var height = $(this).height();
$(".note, .break").each(function () {
$(this).height(height);
});
});
})
我正在为FF寻找一个一致的解决方案或变通方法,以便在iFrame的第一次加载时正确应用高度。
提前谢谢。
方法1:用div get-foat:left包装iframe;并计算fireforx上div的高度。
尝试计算这个div的高度,而不是iframe的高度。。
<div style="float:left">
<iframe></iframe>
</div>
.load()使用
方式2:
$(document).ready(function () {//if u wont define more specific element, use docment ready
$(".event").each(function () {
var height = $(this).height();
$(".note, .break").each(function () {
$(this).css('height':height+'px');//to change css height
//$(this).attr('height',height);//to change inline attr height
});
});
})