Asp.net 当使用ModalPopupXtender作为弹出窗口打开时,出现调整iframe高度的问题
我使用ModalPopupXtender Ajax控件在模式弹出窗口中打开aspx页面。aspx页面在iframe中打开,如下代码所示。在iframe中加载的内容是动态的,因此我不能给iframe一个固定的高度。我想,我应该能够调整高度根据内容,每次弹出窗口被打开。我有一个调整iframe高度的功能,我在其他页面上成功地使用了这个功能,在窗口中填充了iframe,但在弹出窗口中打开iframe时无法调整高度。我已经尝试过window onload、iframe onload事件,但没有成功Asp.net 当使用ModalPopupXtender作为弹出窗口打开时,出现调整iframe高度的问题,asp.net,iframe,height,modalpopupextender,Asp.net,Iframe,Height,Modalpopupextender,我使用ModalPopupXtender Ajax控件在模式弹出窗口中打开aspx页面。aspx页面在iframe中打开,如下代码所示。在iframe中加载的内容是动态的,因此我不能给iframe一个固定的高度。我想,我应该能够调整高度根据内容,每次弹出窗口被打开。我有一个调整iframe高度的功能,我在其他页面上成功地使用了这个功能,在窗口中填充了iframe,但在弹出窗口中打开iframe时无法调整高度。我已经尝试过window onload、iframe onload事件,但没有成功
<asp:ModalPopupExtender ID="ModalPopupExtender2" BackgroundCssClass="transparentBG"
runat="server" CancelControlID="ButtonCancel" OkControlID="ButtonDone"
TargetControlID="btnAddNew" PopupControlID="DivAddWindow" Drag="true" >
</asp:ModalPopupExtender>
<div class="popup_Buttons" style="display: none">
<input id="ButtonDone" value="Done" type="button" />
<input id="ButtonCancel" value="Cancel" type="button" />
</div>
<div id="DivAddWindow" style="display: none;">
<iframe id="IframeEdit" scrolling="no" src="MasterPage.aspx" width="700px">
</iframe>
</div>
如果有人能为我提供解决方案,我将不胜感激。试试这个:
<iframe id="IframeEdit" onload="iframeLoaded()" scrolling="yes" src="MasterPage.aspx" width="700px">
</iframe>
下面的javascript函数将从iframe内容获取高度
<script type="text/javascript">
function iframeLoaded() {
var iFrameID = document.getElementById('IframeEdit');
if (iFrameID) {
iFrameID.height = "";
iFrameID.height = iFrameID.contentWindow.document.body.scrollHeight + "px";
}
}
</script>
函数iframeload(){
var iFrameID=document.getElementById('IframeEdit');
if(iFrameID){
iFrameID.height=“”;
iFrameID.height=iFrameID.contentWindow.document.body.scrollHeight+“px”;
}
}
我甚至在ModalPopupXtender中检查了它,它也可以工作。感谢您的指导。设置scrolling=yes确实解决了高度问题,但在Firefox中,iframe显示水平/垂直滚动。也许我需要找到一种通过CSS隐藏这些内容的方法。