如何在iframe中打印pdf? [英] How do I print a pdf from within an iframe?

查看:1144
本文介绍了如何在iframe中打印pdf?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

cbjsonline.com 上,我正在尝试在iframe中打印pdf自动使用javascript。

At cbjsonline.com, I'm trying to have a pdf in an iframe print automatically with javascript.

目前,我的代码是 - (连接到打开iframe的链接的onclick) - document.getElementById(' fancy_frame')。onload = setTimeout('window.print()',2500);

Currently, my code is - (connected to the onclick of the link that opens the iframe) - document.getElementById('fancy_frame').onload = setTimeout('window.print()',2500);

有什么建议吗?此方法仅适用于safari。

Any suggestions? This method only works in safari.

推荐答案

尝试将函数指针传递给setTimeout,而不是传递eval'd的表达式。

Try passing a function pointer to setTimeout, instead of an expression that gets eval'd.

document.getElementById('fancy_frame').onload = setTimeout( printWindow, 2500 );

// implemented in the HTML that is loaded in 'fancy_frame'
function printWindow()
{
    window.print();
}

这篇关于如何在iframe中打印pdf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆