【问题标题】:Autoheight iFrame Safari BugAutoheight iFrame Safari 错误
【发布时间】:2015-10-17 10:04:26
【问题描述】:

我使用 jquery 根据内容自动调整 iframe 的高度。它在 Firefox 中完美运行,但在 Safari 中它总是给我错误的高度(150px)。

有什么解决办法吗?

function resizeIframe(obj){
     {obj.style.height = 0;};
     {obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';}
  }

【问题讨论】:

    标签: jquery iframe safari resize height


    【解决方案1】:

    尝试使用偏移高度:

    function resizeIframe(obj){
         {obj.style.height = 0;};
         {obj.style.height = obj.contentWindow.document.body.offsetHeight + 'px';}
      }
    

    function resizeIframe(obj) {
        obj.height = obj.contentWindow.document.body.offsetHeight + "px";
    }
    

    【讨论】:

    • 如果这有用,请接受作为答案。否则,请告诉我此解决方案的问题。
    • 感谢您的尝试。在第一个解决方案中,我看不到 iframe(Firefox + Safari)。使用 2. 功能与 Safari 中相同的错误(错误的高度为 150 像素)。
    • 这是链接:cahiers.de/wp/?page_id=21(点击像 Andreas Till VISUAL HAIKU 这样的文章)
    猜你喜欢
    • 2013-05-12
    • 1970-01-01
    • 2019-11-18
    • 1970-01-01
    • 2019-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多