如何使该打印按钮循环遍历所有iframe,而不是一个?

时间:2019-03-07 09:27:56

标签: javascript iframe printing internet-explorer-11

我的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打印方法看到了这一点。请帮忙。

1 个答案:

答案 0 :(得分:0)

尝试参考以下代码:

function printPage() {

    window.print();

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

}