打印页面会自动打开iframe加载

时间:2015-10-04 09:52:59

标签: javascript jquery iframe

我有一个包含3个iFrame的页面。我的问题是当我在浏览器上加载页面时,打印页面会自动打开3次(每个iFrame 1个) 如何使用javascript或jQuery来防止这种情况?

<iframe src="http://uat3.zawya.com/images/iep/cms/docs/halal/aDOC20150909081714_ver-v1.pdf" width="100%" id="english-pdf-viewer" class="pdf-viewer" frameborder="0" scrolling="no"><p>It appears your web browser doesn't support iframes.</p></iframe>

我在页面中有这个代码导致这个问题吗?

$('.pdf-versions').each(function(){
    $(this).on('click', function(){
        $('#' + $(this).attr('name') + '-pdf-viewer').attr('src',$(this).attr('document'));
    });
});

1 个答案:

答案 0 :(得分:0)

您使用的是迭代循环吗?因为它不应该在onclick方法上多次显示它。提供更多代码段。