【精简实用系列】标签自适应高度和宽度
一小段js解决<iframe>标签自适应高度和宽度,自己在IE 火狐 谷歌都测试通过的。
<script type=
"text/javascript"
language=
"javascript"
>
function
iFrameHeight() {
var
ifm= document.getElementById(
"iframepage"
);
var
subWeb = document.frames ? document.frames[
"iframepage"
].document : ifm.contentDocument;
if
(ifm !=
null
&& subWeb !=
null
) {
ifm.height = subWeb.body.scrollHeight;
ifm.width = subWeb.body.scrollWidth;
}
}
</script>
<
iframe
src="index.html" id="iframepage" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" onLoad="iFrameHeight()"></
iframe
>