首页 > 其他 > 详细

iframe高度自适应

时间:2019-10-24 13:33:30      阅读:77      评论:0      收藏:0      [点我收藏+]

1)不跨域 直接获取到iframe中的内容

定时器设置iframe高度

  changeIframeHeight = () => {
    const reinitIframe =  () => {
      let count = 0;
      return () => {
        try {
          const height = this.iframe.contentWindow.document.querySelector('.ant-table-body').offsetHeight + 5
          this.iframe.height = height > 150 ? height : 150;
          count += 1
        } catch (ex) {
          console.log('ex: ', ex);
        }
        return count
      };
    }

    let resetCount = 0
    const reset = reinitIframe()
    const timer = setInterval(() => {
      if (resetCount > 15) {
        clearInterval(timer)
      }
      resetCount = reset()
    }, 300);
  };

iframe高度自适应

原文:https://www.cnblogs.com/coldfrost/p/11731584.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!