iframe高度自动调整问题
我的页面里有一个iframe,这个iframe的src是动态设置的
后台代码:
myTestFrameID.Attributes.Add( "src ", "OrderList.aspx ");
前台代码:
<iframe id= "myTestFrameID " onload= "javascript:{dyniframesize( 'myTestFrameID ');} " runat= "server " width= "100% " scrolling=no frameborder= "0 " > </iframe>
<SCRIPT language= "Javascript ">
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf( "Firefox ")).split( "/ ")[1]
var FFextraHeight=getFFVersion> =0.1? 16 : 0
function dyniframesize(iframename) {
var pTar = null;
if (document.getElementById){
pTar = document.getElementById(iframename);
}
else{
eval( 'pTar = ' + iframename + '; ');
}
if (pTar && !window.opera){
//begin resizing iframe
pTar.style.display= "block "
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
//ns6 syntax
pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight;
}
else if (pTar.Document && pTar.Document.body.scrollHeight){
//ie5+ syntax
pTar.height = pTar.Document.body.scrollHeight;
}
}
}
</SCRIPT>
运行的时候提示:“字符文本中的字符太多”
我如果把src在设计页面的时候固定死,并且把 runat= "server "去掉可以正确执行
我分析了下,问题出现的原因是把iframe设为了 runat= "server ",但是这行在我这里是需要的
大家有没有办法,在iframe的runat= "server "的情况下,能自动调整高度
------解决方案--------------------onload与服务器事件重复
------解决方案-------------------- <iframe id= "myTestFrameID " onload= "javascript:{dyniframesize( 'myTestFrameID ');} " runat= "server " width= "100% " marginwidth= "1 " height= "30 " marginheight= "1 " scrolling= "No " frameborder= "0 " border= "0 ">