!注意此方法用于同一个域名下,可能需要部署在服务器上才能看出效果
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
body {
padding: 0px;
margin: 0px;
}
</style>
<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;
}
}
</script>
</head>
<body>
<iframe src="嵌套页面地址" id="iframepage"
name="iframepage" frameBorder=0 scrolling=no width="100%"
onLoad="iFrameHeight()"></iframe>
</body>