iframe自适应的代码
2007-12-03 16:26
351 查看
<script language="javascript">
function iframeAutoFit()
{
try
{
if(window!=parent)
{
var a = parent.document.getElementsByTagName('IFRAME');
for(var i=0; i<a.length; i++) //author:meizz
{
if(a[i].contentWindow==window)
{
var h = document.body.scrollHeight;
if(document.all) {h += 4;}
if(window.opera) {h += 1;}
a[i].style.height = h;
}
}
}
}
catch (ex)
{
alert('脚本无法跨域操作!');
}
}
if(document.attachEvent) window.attachEvent('onload', iframeAutoFit);
else window.addEventListener('load', iframeAutoFit, false);
</script>
function iframeAutoFit()
{
try
{
if(window!=parent)
{
var a = parent.document.getElementsByTagName('IFRAME');
for(var i=0; i<a.length; i++) //author:meizz
{
if(a[i].contentWindow==window)
{
var h = document.body.scrollHeight;
if(document.all) {h += 4;}
if(window.opera) {h += 1;}
a[i].style.height = h;
}
}
}
}
catch (ex)
{
alert('脚本无法跨域操作!');
}
}
if(document.attachEvent) window.attachEvent('onload', iframeAutoFit);
else window.addEventListener('load', iframeAutoFit, false);
</script>
相关文章推荐
- iframe的大小自动适应嵌入页面大小的代码
- iframe切换内容页仍然能自适应大小代码(含js)
- iframe框架自动适应代码
- Iframe 自动适应页面的高度示例代码
- iframe src为图片时的高度自适应的代码
- jQuery解决iframe高度自适应的一例代码
- 自适应的iframe代码
- 几行JavaScript代码搞定Iframe 自动适应
- jsp页面iframe高度自适应的js代码
- iframe高度自动适应代码
- Iframe 自动适应页面的高度示例代码
- jsp页面iframe高度自适应的js代码
- 网上淘到的很帅的自适应的iframe代码
- iframe高度自动适应代码且浏览器URL改变
- jQuery解决iframe高度自适应的一例代码
- iframe src为图片时的高度自适应的代码
- 让Iframe自适应高度
- JavaScript应用:Iframe自适应其加载的内容高度
- 动态调整Iframe以适应内容(仅同域)
- 才阿ASP同学录v5.3免费版 修改少量代码以适应FireFox