zoukankan      html  css  js  c++  java
  • 利用剪切板实现IFrame跨域自适应高度

    父页:

    <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));">
     

  • 相关阅读:
    Manjaro配置攻略
    Manjaro蓝牙连接问题
    清除所有分区的根目录下的存在隐藏对系统不利的代码的文件
    取消默认磁盘共享
    高手必读 网络端口安全防护技巧放送
    批处理设置虚拟内存
    批处理方式修改IP地址和电脑名
    c++的基本知识
    Windows线程同步与互斥技术总结
    批处理方式设置XP系统的服务程序
  • 原文地址:https://www.cnblogs.com/fromchaos/p/1763594.html
Copyright © 2011-2022 走看看