Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.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/6/google-chrome/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_Css - Fatal编程技术网

Javascript 设置iFrame的高度

Javascript 设置iFrame的高度,javascript,jquery,css,Javascript,Jquery,Css,我试过这个: $('#my_ifr').css('height', '5px !important'); 这是: $('#my_ifr').height(5); 但规模保持不变。当我写作时: $('#my_ifr').height(); 在cosole中,我得到了5,但是当我在Goog中检查元素时,你必须设置他的高度属性 $('#my_ifr').attr('height', '5'); 这个很好用 $('#my_ifr').css('height', '500'); 检查这个,它工作

我试过这个:

$('#my_ifr').css('height', '5px !important');
这是:

$('#my_ifr').height(5);
但规模保持不变。当我写作时:

$('#my_ifr').height();

在cosole中,我得到了5,但是当我在Goog中检查元素时,你必须设置他的
高度
属性

$('#my_ifr').attr('height', '5');
这个很好用

$('#my_ifr').css('height', '500');

检查这个,它工作正常

$('#iframeID').css({'height':'500px'});

但是,你想增加tinymce高度意味着

你这样用,

tinyMCE.init({
...
height : "500"
});

两个答案(@yogi和@Mihai Iorga)都很正确,但看起来你的答案。。。。有几点值得评论:

您没有触发该功能。。。加:

$(function() {
 // Handler for .ready() called.
});

(是一样的…)

现在。。。另一件事是在你的JSFIDLE中,没有iframe#我的ifr


请尝试此更新:


在设置css height属性之前,您需要加载Iframe的内容。 否则,它将保持未定义状态,并且您无法更改height属性

工作代码

setInterval(function(){if(typeof($('#mce_0_ifr').css('height'))=='undefined'){}else{$('#mce_0_ifr').css('height','50px');}},0);

您的html是什么样子的?(请:)@JeroenMons我有一个简单的html,里面有tinymce。你能提供一个解决你问题的方法吗?@JeroenMons你想把它的高度设置为5px是什么?中间的白色文本区域?
$(document).ready(function() {
  // Handler for .ready() called.
});
$(function() {
    // Not Valid
    //$('#mce_0_ifr').height(5);

    // Valid - by @yogi
    $('#my_ifr').css('height', '500');

    // Valid - by @Mihai Iorga only if no attr was previulsy set
    // but be carefull because pre-defined element.style or css rule
    // will overright the atribute (attr)
    $('#my_ifr').attr('height', '5');
    // That is, the iframe will have 500 and not 5
});​
setInterval(function(){if(typeof($('#mce_0_ifr').css('height'))=='undefined'){}else{$('#mce_0_ifr').css('height','50px');}},0);