<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"></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 都不管用。 请各位高手帮帮忙,如何让高度自适。
<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"></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 都不管用。 请各位高手帮帮忙,如何让高度自适。
解决方案 »
- 在repeater控件的HeaderTemplate取出Literal控件并赋值?
- 必须声明标量变量 "@regionand"。
- 遇到一个图片防盗很牛的老外的网站!高手进来研究一下!
- 关于超链接打开excel的问题
- 急!!! FreeTextBox的自动换行问题
- 密码验证的加密算法
- 如何合并结构完全相同的DATASET?
- C#中怎么做到这样的stylevar["charset"]下标为字符串的数组?
- asp.net 后台如何调用OCX控件的事件?
- WINDOWS.NET 和VS.NET中使用ASP。NET的问题。急!!在线等
- 只安装MSDN帮助文件
- 第 1 行: 'form' 附近有语法错误。
parent.document.all("框架ID名").style.height=document.body.scrollHeight;
=>>
document.all("框架ID名").height=document.all("框架ID名").contentWindow.document.body.scrollHeight;
name="frmsrc"
<script type="text/javascript">
function auto()
{
document.all("frmsrc").height=document.all("frmsrc").contentWindow.document.body.scrollHeight;
}
</script>
<body onload="auto()">
我这样用的,iframe也加 name="frmsrc" 高度还是固定的。。
function iframeAutoFit()
{
try
{
var iframes = document.getElementsByTagName("IFRAME");
for(var i=0; i<iframes.length; i++) //author:meizz
{
if (iframes[i] && !window.opera)
{
iframes[i].style.display="block"
if (iframes[i].contentDocument && iframes[i].contentDocument.body.offsetHeight)//如果用户的浏览器是NetScape
{
iframes[i].height = iframes[i].contentDocument.body.offsetHeight;
}
else if (iframes[i].Document && iframes[i].Document.body.scrollHeight) //如果用户的浏览器是IE
{
iframes[i].height = iframes[i].Document.body.scrollHeight;
}
}
}
}
catch (ex){}
}if(window.attachEvent)
{
window.attachEvent("onload", iframeAutoFit);
//window.attachEvent("onresize", iframeAutoFit);
}
else if(window.addEventListener)
{
window.addEventListener('load', iframeAutoFit, false);
//window.addEventListener('resize', iframeAutoFit, false);
}
我的iframe 的id 也是变量 id="<%# Eval("roomid")%>"
{
var roomid = window.location.href
roomid = roomid.substr(roomid.lastIndex("/"))
roomid = roomid.substr(0,roomid.indexOf(".")
parent.document.getElementById("frmsrc" + roomid).style.height=document.body.scrollHeight;
}
<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<%# Eval("roomid")%>" marginheight="0"></iframe></span></td>在<%# Eval("roomid")%>.htm里面写window.onload = function()
{
var roomid = window.location.href
roomid = roomid.substr(roomid.lastIndex("/"))
roomid = roomid.substr(0,roomid.indexOf(".")
alert(roomid) //看是否是正确的id
var eleHeight
if(document.documentElement)
eleHeight = document.documentElement.scrollHeight
else
eleHeight = document.body.scrollHeight parent.document.getElementById("frmsrc" + roomid).style.height=eleHeight + "px";
}
window.onload = function()
{
var roomid = window.location.href
roomid = roomid.substr(roomid.lastIndexOf("/")+1)
roomid = roomid.substr(0,roomid.indexOf("."))
var eleHeight
if(document.documentElement)
eleHeight = document.documentElement.scrollHeight
else
eleHeight = document.body.scrollHeight parent.document.getElementById("frmsrc" + roomid).style.height=eleHeight + "px";
}</script>
<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>