Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.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
jQuery:100%高度iframe处于引导模式_Jquery_Iframe_Bootstrap 4_Bootstrap Modal - Fatal编程技术网

jQuery:100%高度iframe处于引导模式

jQuery:100%高度iframe处于引导模式,jquery,iframe,bootstrap-4,bootstrap-modal,Jquery,Iframe,Bootstrap 4,Bootstrap Modal,我有一个php脚本,可以生成要打印的文档。我正试图让这个脚本以100%的宽度和高度进入Bootstrap4模式,这样客户端就可以检查内容,然后打印出来 <button type="button" id="print_modal" class="btn btn-primary" data-toggle="modal" data-target="#printmodal">Result</button> <div class="modal fade" id="printm

我有一个php脚本,可以生成要打印的文档。我正试图让这个脚本以100%的宽度和高度进入Bootstrap4模式,这样客户端就可以检查内容,然后打印出来

<button type="button" id="print_modal" class="btn btn-primary" data-toggle="modal" data-target="#printmodal">Result</button>
<div class="modal fade" id="printmodal">
    <div class="modal-dialog" style="max-width:210mm !important">
        <div class="modal-content">
          <div class="modal-header">
            <button class="btn btn-primary ml-1" id="print_btn">Tisk</button>
            <button type="button" class="close" data-dismiss="modal">&times;</button>
          </div>
          <div class="modal-body text-left" id="print_content">
            <!-- IFRAME HERE -->
          </div>
        </div>
    </div>
</div>
我需要像超时这样的东西来检查iframe填充后的高度,但我不知道怎么做

不工作:

在生成的iframe上使用onload参数:(返回0px-model FadeIn可能比iframe append慢…)


函数ifrhgh(){
变量iframehght=$(“#打印框”).contents().height();
}

此部分由按钮触发,该按钮也显示模式。所以模态应该在iframe加载之前打开

$('#print_modal').click(function () {
  $('#print_content').html('<iframe src="./index.php?print" frameborder="0" scrolling="no" id="print_frame"></iframe>');
});

此部分由按钮触发,该按钮也显示模式。所以模态应该在iframe加载之前打开

$('#print_modal').click(function () {
  $('#print_content').html('<iframe src="./index.php?print" frameborder="0" scrolling="no" id="print_frame"></iframe>');
});
已解决: 关键是在显示的
上创建iframe。bs.modal
(成功加载后由modal触发的BS4事件),然后onload参数调用将iframe设置为content的
ifrhgh()
函数

$(function () {
    $('#printmodal').on('shown.bs.modal', function () {
        $('#print_content').html('<iframe width="100%" onload="ifrhgh()" src="./index.php?print" frameborder="0" scrolling="no" id="print_frame"></iframe>');
    });
});

function ifrhgh(){
    var iframehght =  $("#print_frame").contents().height();
    $("#print_frame").height(iframehght);
}
$(函数(){
$('#printmodel').on('show.bs.modal',function(){
$(“#打印内容”).html(“”);
});
});
函数ifrhgh(){
变量iframehght=$(“#打印框”).contents().height();
$(“#打印框”)。高度(iframehght);
}
已解决: 关键是在显示的
上创建iframe。bs.modal
(成功加载后由modal触发的BS4事件),然后onload参数调用将iframe设置为content的
ifrhgh()
函数

$(function () {
    $('#printmodal').on('shown.bs.modal', function () {
        $('#print_content').html('<iframe width="100%" onload="ifrhgh()" src="./index.php?print" frameborder="0" scrolling="no" id="print_frame"></iframe>');
    });
});

function ifrhgh(){
    var iframehght =  $("#print_frame").contents().height();
    $("#print_frame").height(iframehght);
}
$(函数(){
$('#printmodel').on('show.bs.modal',function(){
$(“#打印内容”).html(“”);
});
});
函数ifrhgh(){
变量iframehght=$(“#打印框”).contents().height();
$(“#打印框”)。高度(iframehght);
}

这两个代码段完全相同。。。。fixedTry
$(this).contents().height()
如果在您尝试测量时,作为此处容器的模态被隐藏,则高度将为零。这两个代码段是相同的sorry。。。。fixedTry
$(this).contents().height()
如果在尝试测量时隐藏了此处的容器,则高度将为零。运气不好。这仅适用于动态除法、跨距..等,并且仅适用于“单击”触发器。使用iframe时,即使使用“click”也不起作用。这只适用于动态div、span..等,并且只适用于“click”触发器。使用iframe时,即使使用“单击”也不起作用
$(document).on("load","#print_frame",function(){
  var iframeHeight = $(this).contents().height();
  console.log(iframeHeight);  // Check the console for that value.

  $(this).height(iframeHeight);
});
$(function () {
    $('#printmodal').on('shown.bs.modal', function () {
        $('#print_content').html('<iframe width="100%" onload="ifrhgh()" src="./index.php?print" frameborder="0" scrolling="no" id="print_frame"></iframe>');
    });
});

function ifrhgh(){
    var iframehght =  $("#print_frame").contents().height();
    $("#print_frame").height(iframehght);
}