将 url 的内容发送到打印机
我知道我可以通过调用打印当前页面
javascript:windows.print()
是否可以打印页面而不先显示它?我的意思是,如果我有一个链接,我想将 target_url 的内容发送到打印机。
<a href="target_url">Click to print the target_url</a>
我可以用ajax加载它,但是有办法将此内容发送到打印机吗?
谢谢。
I know that I can print the current page by calling
javascript:windows.print()
Is it possible to print a page without showing it first? I mean if I have a link I would like to send to the printer the content of the target_url.
<a href="target_url">Click to print the target_url</a>
I can load it with ajax, but there's anyway to send this content to the printer?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 iframe 怎么样?加载不可见的 iframe 中的内容,然后打印该 iframe。
What about using an iframe? Load the contents in an iframe that is not visible and then print the iframe.
您可以将内容加载到隐藏框架中,然后让它调用
window.print()
。这将导致向用户显示浏览器的本机“打印”对话框。未经用户批准,您不能强制客户端计算机开始打印某些内容。You could load your content into a hidden frame and then have it call
window.print()
. That will result in the browser's native "Print" dialog being shown to the user. You cannot force the client machine to start printing something without user approval.