Jquery 如何将全高iframe插入空白WordPress仪表板?

Jquery 如何将全高iframe插入空白WordPress仪表板?,jquery,wordpress,iframe,Jquery,Wordpress,Iframe,当我试图制作一个空白的WordPress仪表板并在空白处插入一个iframe时,我发现iframe只能有一个固定的高度 但是要很好地集成这种定制,需要100%的高度 在这篇文章中,我编写了一种技术来制作一个完全空白的仪表板,隐藏图标和标题、屏幕选项和所有小部件(默认和由插件添加) 如果我使用下面的jQuery注入iframe,它不会占据100%的高度,无论我向管理样式表中添加了什么CSS $('#wpbody').html( '<iframe src="http://examp

当我试图制作一个空白的WordPress仪表板并在空白处插入一个iframe时,我发现iframe只能有一个固定的高度

但是要很好地集成这种定制,需要100%的高度

在这篇文章中,我编写了一种技术来制作一个完全空白的仪表板,隐藏图标和标题、屏幕选项和所有小部件(默认和由插件添加)


如果我使用下面的jQuery注入iframe,它不会占据100%的高度,无论我向管理样式表中添加了什么CSS

$('#wpbody').html(
    '<iframe src="http://example.com" 
     frameborder="0" id="myframe"  
     style="height:100%;margin:0;padding:0;left:0;top:0" 
     scrolling="auto" width="100%" height="100%"></iframe>'
); 
$('wpbody').html(
''
); 

问题是:如何让iframe填满所有的
#wpbody
空间并保持这种状态?

在这方面找到了解决方案(谢谢大家,Jim,代码很漂亮!)

此外,以下内容将在仪表板屏幕内显示全尺寸iframe

add_action( 'admin_head-index.php', 'wpse_73561_dashboard_scripts' );

function wpse_73561_dashboard_scripts() 
{
    ?>
        <style>
            .wrap h2, .postbox .handlediv, #icon-index { display:none }
            #wpcontent { margin-left:0 !important }
        </style>
        <script language="javascript" type="text/javascript">   
            function sizeIFrame() 
            {
                var helpFrame = jQuery("#myframe");
                var innerDoc = (helpFrame.get(0).contentDocument) 
                ? helpFrame.get(0).contentDocument 
                : helpFrame.get(0).contentWindow.document;

                helpFrame.height(innerDoc.body.scrollHeight + 35);
            }

            jQuery(function() 
            {
                sizeIFrame();
                jQuery("#myframe").load(sizeIFrame);
            });

            jQuery(document).ready(function($) 
            {
                $('#wpbody').html(
                    '<iframe src="http://example.com" 
                     frameborder="0" id="myframe" 
                     style="margin:0;padding:0;left:0;top:0" 
                     scrolling="auto" 
                     width="100%" height="100%"></iframe>'
                );
            });
        </script>   
    <?php
}
add_操作('admin_head-index.php','wpse_73561_dashboard_scripts');
函数wpse_73561_仪表板_脚本()
{
?>
.wrap h2、.postbox.handlediv、#图标索引{display:none}
#wpcontent{左边距:0!重要}
函数sizeIFrame()
{
var helpFrame=jQuery(“#myframe”);
var innerDoc=(helpFrame.get(0.contentDocument)
?helpFrame.get(0).contentDocument
:helpFrame.get(0).contentWindow.document;
helpFrame.height(innerDoc.body.scrollHeight+35);
}
jQuery(函数()
{
sizeIFrame();
jQuery(“#myframe”).load(sizeIFrame);
});
jQuery(文档).ready(函数($)
{
$('#wpbody').html(
''
);
});

事实上,我不确定代码的作者是谁…我只是在事后检查了一下,对我来说,指向链接的点…谁知道?…只有影子知道。。。