js 对iframe 高的控制
function SetCwinHeight(frameID) {
var iframeid = window.document.getElementById(frameID); //iframe id
if (document.getElementById) {
if (iframeid && !window.opera) {
if (iframeid.contentDocument && iframeid.contentDocument.body.offsetHeight) {
iframeid.height = iframeid.contentDocument.body.offsetHeight;
} else if (iframeid.Document && iframeid.Document.body.scrollHeight) {
iframeid.height = iframeid.Document.body.scrollHeight;
}
}
}
}
html代码:
<iframe src="MainIndex.aspx" id="mainFrame" name="mainFrame" frameborder="0" scrolling="no"
onload="Javascript:SetCwinHeight('mainFrame')" style="padding: 0; margin: 0;
border: 0; 100%;"></iframe>