【问题标题】:How do I make this print button loop through all iframes instead of just one?如何使此打印按钮循环遍历所有 iframe 而不仅仅是一个?
【发布时间】:2019-03-07 09:27:55
【问题描述】:

我的 iframe:

<iframe name="pictoframeaerial" 
src="https://explorer.pictometry.com/login.php""></iframe>
<iframe name="pictoframeoblique" 
src="https://explorer.pictometry.com/login.php" "></iframe>
<iframe id="street" class="zoom" name="street" 
src="http://localhost/streetview.html" ></iframe>

我的按钮:

$('#print').click(function ()
{
    var contentWindow = document.getElementById("street").contentWindow;
    var result = contentWindow.document.execCommand('print', false, null);
    if(!result)  contentWindow.print();
})

谢谢。我已经看到使用 window.frames 打印方法完成了这项工作。请帮忙。

【问题讨论】:

    标签: javascript iframe printing internet-explorer-11


    【解决方案1】:

    尝试参考以下代码:

    function printPage() {
    
        window.print();
    
        for (var k = 0; k < window.frames.length; k++) {
            window.frames[k].focus();
            window.frames[k].print();
        }
    
    }
    

    【讨论】:

    • 谢谢。此代码不适用于 ie 11。另一个可以。虽然我想循环播放多个帧而不是一个。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-04
    • 2021-11-03
    • 2021-11-20
    • 1970-01-01
    相关资源
    最近更新 更多