我的页面中引入一个iframe 然后这个iframe外有个div 我现让iframe增高了之后我这个div也自动增高。 现在效果是,iframe显示区域不完整。各位帮帮忙!!!
解决方案 »
- 一段处理URL的代码...有看的懂的请详细的介绍下
- 关于建设读取显示数据问题
- C# net 有哪些好的架构?搭建需要那些工具?
- 关于freetextbox的问题
- asp.net(c#)实现-网页聊天&在线交互 体会与求助
- 灵异事件?
- 帮忙指点一下 在线等结果 先谢谢了~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
- DataList内ListBox控件的SelectedIndexChanged事件怎样获得
- 前天的问题,到现在连续发了4张贴子,还未解决,救命啊!~~~~
- .NET我的VS上怎么没有Response.Headers属性如何解决
- asp.net如何在我自己的网页中播放优酷视频?
- 如何在ASP.NET中写一段判断数据库中数量的值是否为负数
//现获取div的高度:
var divHeight = document.getElementById("left").style.height;
//给iframe一个id=main,获取它并赋值
document.getElementById("main").style.height= divHeight
</script>
.div {width:auto; height:auto;}
</style>
这样不可以吗?
<div style='width:auto; height:auto;backgound:#000; padding:10px; border:1px solid #f00;'>
<iframe wdith='100' height="150"></iframe>
</div>我刚才试了下,可以啊
<div style='width:auto; height:auto;backgound:#000; padding:10px; border:1px solid #f00;'>
<iframe wdith='100' height="150" src="这里嵌入页面你试试"></iframe>
</div>
你这个需要js来实现。
先获取iframe里src 页面的高度,在用js把iframe的高度设置一下,就可以了。
我的iframe高度是增高了。 div的告诉我设置的是 auto 可是不行啊。
function dyniframesize(down) {
var pTar = null;
if (document.getElementById){
pTar = document.getElementById(down);
} else{
eval('pTar = ' + down + ';');
}
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 +20;
pTar.width = pTar.contentDocument.body.scrollWidth+20;
}
else if (pTar.Document && pTar.Document.body.scrollHeight){
//ie5+ syntax
pTar.height = pTar.Document.body.scrollHeight;
pTar.width = pTar.Document.body.scrollWidth;
}
}
} <iframe onload="javascript:dyniframesize('userArea');" id="userArea" name="userArea" frameborder="0" style="width:100%;display:none;" src="org_loadAllUser.do?parentId=${parentId}&type=${type}&parentname=${parentname}" frameborder="0" marginheight="0" marginwidth="0" frameborder="0" scrolling="auto"></iframe>
1,你的div 高度可以设置auto;
2,你主要控制iframe的高就可以了var iframe = document.getElementById("iframeID");
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height = height;
}catch (ex){}
windows.setinterval("你的js()",1000)
http://www.iteye.com/topic/209530
我觉得用iframe最好固定一个高宽,让里面内容完全显示那样就不会出现滚动条,如果内容过多有滚动条也在所难免的!
<div style="height:300px;display:table;>
var iframe = document.getElementById("iframe01");
try{
iframe.height = iframe.contentWindow.document.documentElement.scrollHeight;
}catch (ex){}
}