T
toha
Здравствуйте. Помогите пожалуйста по следующему вопросу. Мне нужно зделать так чтобы iframe автоматически растягивался по высоте загружаемого в него окна. Есть код:
В IE все нормально работает, в Opera 9.52 тоже нормально а вот в Opera 9.27 этот iframe становится почти в 2 раза больше чем надо а в мозилле он становится каким надо по размеру только после обновления страницы. Может есть какиенибудь кроссбраузерные скрипты по этой теме или этот скрипт можно настроить под особенности разных браузеров.
Код:
<script type="text/javascript">
<!--
var timeout;
function clickAction() {
frameFitting();
var fr = document.getElementById('demo_frame').contentWindow.document.body.getElementsByTagName('a');
for (var i=0; i<fr.length; i++) {
fr[i].onclick = function() {
clearInterval(timeout);
timeout = setInterval("frameFitting()",100);
}
}
}
function frameFitting() {
document.getElementById('demo_frame').width = '100%';
document.getElementById('demo_frame').height = document.getElementById('demo_frame').contentWindow.document.body.scrollHeight+4+'px';
}
onload = clickAction;
//-->
</script>
Код:
<iframe src="pred.html" style='width: 100%;' frameborder=5 marginheight=0 marginwidth=0 onload='o=this.contentWindow.document.body; this.style.height=o.scrollHeight; this.style.height=o.scrollHeight-o.clientHeight+o.offsetHeight;' id="demo_frame" name="content" hspace=0 height="500px"></iframe>