如何打印未加载的网页?
我在网页中,我希望当我单击“打印”链接时,打开“打印框”并能够打印其他页面。我有要打印的网页的 href。
I'm in a webpage and I would like that when I click on a "print" link, open the "print box" and be able to print other page. I have the href of the webpage that I want to print.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以让打印按钮以另一个页面作为 URL 打开一个新窗口,并让该页面在 onload 处理程序中触发 window.print() 。或者像 @darin 建议的那样使用 CSS 媒体查询是唯一的方法。
You can have your print button open a new window with the other page as the URL, and have that page fire window.print() in the onload handler. That or using CSS media queries like @darin suggested is the only way.
那是不可能的。决定在浏览器中打印什么内容的是用户,而不是您。因此,只需在页面中提供指向该其他网站的链接并邀请用户导航至该网站并打印即可。如果您想更改样式,您还可以为当前页面应用 打印 CSS。
That's not possible. It's the user that decides what he wants to print in his browser, not you. So simply provide a link to this other site in your page and invite the user to navigate to it and print it. You could also apply a print CSS for the current page if you want to change the style.