Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 调整Iframe高度_Javascript_Jquery_Html_Iframe - Fatal编程技术网

Javascript 调整Iframe高度

Javascript 调整Iframe高度,javascript,jquery,html,iframe,Javascript,Jquery,Html,Iframe,是否有任何方法可用于动态调整iframe(加载外部站点)的高度 或 有没有办法检查iframe是否有滚动条?试试以下方法: // Get the iFrame jQuery Object var $MyFrame = $("#iframeid"); // You need to wait for the iFrame content to load first // So, that the click events work properly $MyFrame.load(function (

是否有任何方法可用于动态调整iframe(加载外部站点)的高度

有没有办法检查iframe是否有滚动条?

试试以下方法:

// Get the iFrame jQuery Object
var $MyFrame = $("#iframeid");

// You need to wait for the iFrame content to load first
// So, that the click events work properly
$MyFrame.load(function () {
    var frameBody = $MyFrame.contents().find('body');

    // Set the iFrame height
    $MyFrame.css({
        height: frameBody.outerHeight()
    });
});

我相信这就是你要找的是的,但对我来说什么都不管用。我正在尝试从外部站点加载文档:(因为当iframe来自另一个域时,您无法访问任何内容,因此只有当远程站点“帮助”您时,这才起作用–就像Facebook对画布/页面选项卡应用程序所做的那样,他们进行一些跨域通信,以便iframe页面将自己的高度发送给父级。