GridView 中使用iframe高度问题
<asp:GridView ID= "GVItemList " runat= "server " AutoGenerateColumns= "False " EnableTheming= "True " GridLines= "None ">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table border= "0 " cellpadding= "0 " cellspacing= "0 " style= "width:700px ">
<tr>
<td> <span style= "color:#003399; font-size:3 "> <iframe src= "http://192.168.1.6:81/html/PM/ <%# Eval( "roomid ")%> .htm " width= "700px " frameborder= "0 " id= "frmsrc " marginheight= "0 " onload= "javascript:{dyniframesize( 'frmsrc ');} "> </iframe> </span> </td>
</tr>
</table>
</ItemTemplate>
<ItemStyle CssClass= "ContextMenuColumn " />
</asp:TemplateField>
</Columns>
</asp:GridView>
如上我在GridView中使用模板列中的iframe 连接不同htm页面(没有跨域),但高度不能动态改变,每个htm页面的高度不同的,我用过类似
parent.document.all( "框架ID名 ").style.height=document.body.scrollHeight;
很多javascript 都不管用。 请各位高手帮帮忙,如何让高度自适。
------解决方案-------------------- <script type= "text/javascript ">
function dyniframesize(id)
{
AutoIframe(id);
}
function AutoIframe(id)
{
if(document.readyState!= 'complete ')
{
setTimeout( function(){AutoIframe(id);},25 );
return;
}
else
{
var ifobj=document.getElementById(id);
ifobj.height= ifobj.contentWindow.document.body.scrollHeight;
}
}
</script>