Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.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_Iframe_Resize_Height - Fatal编程技术网

Javascript 如何获得真实的iframe身高?

Javascript 如何获得真实的iframe身高?,javascript,iframe,resize,height,Javascript,Iframe,Resize,Height,我的身体高度有一些奇怪的问题 在我的编辑器中,键入区域的大小是可调整的,因此在14行之后,递增停止并显示一个滚动条。删除某些行后,滚动条将隐藏,高度应开始降低。但它不。。。因为在滚动条隐藏后,我无法读取真实的iframe体高 你可以在这里找到我的编辑器:-身体高度低于编辑器,每100毫秒更新一次 顺便说一句,萤火虫用它的真实尺寸来标记身体,而不是这辆车 我使用的代码是: var s = document.getElementById(rte); var x = s.contentWindow.d

我的身体高度有一些奇怪的问题

在我的编辑器中,键入区域的大小是可调整的,因此在14行之后,递增停止并显示一个滚动条。删除某些行后,滚动条将隐藏,高度应开始降低。但它不。。。因为在滚动条隐藏后,我无法读取真实的iframe体高

你可以在这里找到我的编辑器:-身体高度低于编辑器,每100毫秒更新一次

顺便说一句,萤火虫用它的真实尺寸来标记身体,而不是这辆车

我使用的代码是:

var s = document.getElementById(rte);
var x = s.contentWindow.document;
var timer = setInterval(function()
{
        var h = x.body.scrollHeight;
        $('.aasdf').text(h);
        if(h > maxheight)
        {
            $(s).height(maxheight);
            x.body.parentNode.style.overflow = "auto";
            clearInterval(timer);
        }
        else if(h <= minheight)
            $(s).height(minheight);
        else
        {
            x.body.parentNode.style.overflow = "hidden";
            $(s).height(h);
        }           
}, 100);
var s=document.getElementById(rte);
var x=s.contentWindow.document;
var timer=setInterval(函数()
{
var h=x.body.height;
$('.aasdf')。文本(h);
如果(h>最大高度)
{
$(s).高度(最大高度);
x、 body.parentNode.style.overflow=“自动”;
清除间隔(计时器);
}
否则(h

函数更改()
{
var a=document.getElementById('if');
var b=a.样式.高度;
警报(b);
}
此代码将帮助您获得iframe的高度..!这可能会有所帮助。 祝你今天愉快

<iframe style="height:200px" id="if" onload="change()"></iframe>

<script type="text/javascript">
function change()
{
    var a = document.getElementById('if');
    var b = a.style.height;
    alert(b);
}
</script>