将 url 的内容发送到打印机

发布于 2024-10-08 12:51:11 字数 283 浏览 0 评论 0原文

我知道我可以通过调用打印当前页面

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白芷 2024-10-15 12:51:11

使用 iframe 怎么样?加载不可见的 iframe 中的内容,然后打印该 iframe。

What about using an iframe? Load the contents in an iframe that is not visible and then print the iframe.

始于初秋 2024-10-15 12:51:11

您可以将内容加载到隐藏框架中,然后让它调用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文