ITPub博客

首页 > 应用开发 > IT综合 > 去掉iframe横向滚动条_iframe滚动条

去掉iframe横向滚动条_iframe滚动条

原创 IT综合 作者:jyb2014 时间:2014-10-08 16:13:23 0 删除 编辑
主页面加IFRAME SCROLLING="YES"
子页面
'让竖条消失: 
 
 
'让横条消失: 
 

'还要去掉
'子页面里的

'两个都去掉
iframe自动适应页面大小JS函数
//Iframe自适应高度/宽度  
function dynIframeAutoSize(iFrameName,autoType) 
{ 
debugger 
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]; 
//extra height in px to add to iframe in FireFox 1.0+ browsers 
//高度 
var FFextraHeight=getFFVersion>=0.1? 16 : 0 ; 
//宽度 
var FFextraWidth=getFFVersion>=0.1? 16 : 0 ; 
var objElement = null; 
if (document.getElementById) 
objElement = document.getElementById(iFrameName); 
else 
eval('pTar = ' + iFrameName + ';'); 
if (objElement && !window.opera) 
{ 
//begin resizing iframe 
objElement.style.display="block"; 
switch(autoType) 
{ 
case "height": 
//高度 
if (objElement.contentDocument && objElement.contentDocument.body.offsetHeight) 
//ns6 syntax 
objElement.height = objElement.contentDocument.body.offsetHeight+FFextraHeight; 
else if (objElement.Document && objElement.Document.body.scrollHeight) 
//ie5+ syntax 
objElement.height = objElement.Document.body.scrollHeight; 
break; 
case "width": 
//宽度 
if (objElement.contentDocument && objElement.contentDocument.body.offsetWidth) 
//ns6 syntax 
objElement.width = objElement.contentDocument.body.offsetWidth+FFextraWidth; 
else if (objElement.Document && objElement.Document.body.scrollWidth) 
//ie5+ syntax 
objElement.width = objElement.Document.body.scrollWidth; 
break; 
default: 
//适应大小(高和宽)  
//高度 
if (objElement.contentDocument && objElement.contentDocument.body.offsetHeight) 
//ns6 syntax 
objElement.height = objElement.contentDocument.body.offsetHeight+FFextraHeight; 
else if (objElement.Document && objElement.Document.body.scrollHeight) 
//ie5+ syntax 
objElement.height = objElement.Document.body.scrollHeight; 
//宽度 
if (objElement.contentDocument && objElement.contentDocument.body.offsetWidth) 
//ns6 syntax 
objElement.width = objElement.contentDocument.body.offsetWidth+FFextraWidth; 
else if (objElement.Document && objElement.Document.body.scrollWidth) 
//ie5+ syntax 
objElement.width = objElement.Document.body.scrollWidth; 
break; 
} 
} 
}
方法一:在父页面中

iframe中页面:
function window.onload()
{
var div = window.parent.document.getElementById('div1');
div.style.height=document.body.scrollHeight+20;
}
方法二:

使用的时候只要贴在里面就可以了

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29753604/viewspace-1291839/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-07-15

  • 博文量
    101
  • 访问量
    196521