iframe根据子frame的高度自动高度
2024-10-20 15:54:17
<script type="text/javascript">
//光标移动到顶部
this.to_top=function(){
$("html,body").animate({scrollTop:0}, 500);
} this.setCwinHeight=function (iframeObj) { /* 8、获取iframe的高度
iframe.contentWindow.document.body.offsetHeight;
如果要获取iframe中的iframe
document.getElementById('iframId').onload=function(){
var html= window.frames["name属性"].frames["name属性"].document.getElementById('iframe中的元素的id').innerHTML; $('#iframeId').load(function() { //方法1
var iframeHeight = Math.min(iframe.contentWindow.window.document.documentElement.scrollHeight, iframe.contentWindow.window.document.body.scrollHeight);
var h=$(this).contents().height();
$(this).height(h+'px');
});
*/
if (document.getElementById) {
if (iframeObj && !window.opera) {
if (iframeObj.contentDocument
&& iframeObj.contentDocument.body.offsetHeight) {
if (a = iframeObj.getAttribute("id") == "video_top") {
iframeObj.height = iframeObj.contentWindow.document.body.offsetHeight;
} else if (iframeObj.getAttribute("id") == "video_bottom") {
iframeObj.height = iframeObj.contentWindow.document.body.offsetHeight;
} else if (document.frames[0].contentWindow
&& document.frames[0].contentWindow.document.body.scrollHeight) {
var height = document.frames[0].document.body.scrollHeight;
}
}
}
}
}
</script>
//src为子frame间接路径
<iframe id="video_bottom" src="${pageContext.request.contextPath}/vcomment/videoBottom/${videoId}.htm" width="90%" frameborder="0" scrolling="no" onload="setCwinHeight(this);"></iframe>
最新文章
- Linux.NET学习手记(6)
- JavaScript语言精粹--Function,类,this,对象
- bzoj3668: [Noi2014]起床困难综合症
- Qt4.8.6+mingw+Qgis2.4.0基于QGis的二次开发
- spring quartz 定时任务“Failed to load class ";org.slf4j.impl.StaticLoggerBinder”“Checking for available updated version of Quartz”
- Marzoni(玛佐尼)意大利顶级西服面料之一_HollandandSherry_新浪博客
- css案例学习之id要唯一
- git ssh认证
- 梳排序(Comb sort)
- MapReduce深度分析(一)
- TF.VARIABLE、TF.GET_VARIABLE、TF.VARIABLE_SCOPE以及TF.NAME_SCOPE关系
- undo系统参数详解
- python_装饰器
- python全栈开发day86-CRM增删改查 分页
- xmlSpy套件(Altova MissionKit 2016)的Ollydbg调试过程及破解
- 学习windows编程 day4 之 多边矩形填充
- (ecj)Eclipse的Java编译器分析之一——ecj介绍
- django后台的制作
- tomcat8 tomcat-users相关配置
- How to turn on syntax highlighting in osx