利用剪切板实现IFrame跨域自适应高度
2010-06-23 14:41
471 查看
父页:
<script type="text/javascript">
/*----------------------------------------------------------'
'函数名称: ResetIframeHeight()
'函数功能: Iframe高度自适应函数
'
'参数说明:
'参数名称 参数类型 参数含义
'无
'
'修改人 修改时间 修改摘要
'zhangzd 2010/06/23 初次创建
'-----------------------------------------------------------*/
function ResetIframeHeight()
{
try
{
var strText=window.clipboardData.getData('text'); //从剪切板获取iframe嵌套页面中设置的text数据
var fraDetail=document.getElementById('fraDetail'); //iframe对象
//text数据是否含有frameHeight=的字样
if(strText.match(/^frameHeight=\d+$/))
{
//设置iframe高度
fraDetail.style.height=parseInt(strText.match(/\d+/))+'px';
//清空剪切板数据
window.clipboardData.setData('text','null');
}
}
catch(e){}
//设置运行时间
setTimeout(ResetIframeHeight,500);
};
ResetIframeHeight();
</script>
被嵌套页:
<body onload="window.clipboardData.setData('text',String('frameHeight='+window.document.body.scrollHeight));">
<script type="text/javascript">
/*----------------------------------------------------------'
'函数名称: ResetIframeHeight()
'函数功能: Iframe高度自适应函数
'
'参数说明:
'参数名称 参数类型 参数含义
'无
'
'修改人 修改时间 修改摘要
'zhangzd 2010/06/23 初次创建
'-----------------------------------------------------------*/
function ResetIframeHeight()
{
try
{
var strText=window.clipboardData.getData('text'); //从剪切板获取iframe嵌套页面中设置的text数据
var fraDetail=document.getElementById('fraDetail'); //iframe对象
//text数据是否含有frameHeight=的字样
if(strText.match(/^frameHeight=\d+$/))
{
//设置iframe高度
fraDetail.style.height=parseInt(strText.match(/\d+/))+'px';
//清空剪切板数据
window.clipboardData.setData('text','null');
}
}
catch(e){}
//设置运行时间
setTimeout(ResetIframeHeight,500);
};
ResetIframeHeight();
</script>
被嵌套页:
<body onload="window.clipboardData.setData('text',String('frameHeight='+window.document.body.scrollHeight));">
相关文章推荐
- 完美实现跨域Iframe高度自适应【Iframe跨域高度自适应解决方案】
- 完美实现跨域Iframe高度自适应【Iframe跨域高度自适应解决方案】
- 跨域实现IFRAME自适应高度
- 跨域实现IFRAME自适应高度
- javascript跨域通信(一):利用location.hash实现跨域iframe自适应
- 完美实现跨域Iframe高度自适应【Iframe跨域高度自适应解决方案】
- IFrame跨域高度自适应实现代码
- 完美实现跨域Iframe高度自适应【Iframe跨域高度自适应解决方案】
- 实现跨域Iframe高度自适应调整
- CSS完美实现iframe高度自适应(支持跨域)
- IFrame跨域高度自适应实现代码
- 2级域名实现iframe域名跨域自适应高度
- 利用location.hash实现跨域iframe自适应
- 跨域实现IFRAME自适应高度~续(终级)
- iframe自适应内层页面高度,可响应页面中折叠点击事件,以及实现跨域的问题解决方案
- 完美实现跨域Iframe高度自适应
- 跨域iframe高度自适应(兼容IE/FF/OP/Chrome)
- 教你用jquery实现iframe自适应高度
- 跨域iframe高度自适应(兼容IE/FF/OP/Chrome)
- 如何设置iframe高度自适应在跨域情况下的可用方法