php 如何打印网页

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5878562/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:45:56  来源:igfitidea点击:

how to print a web page

phphtml

提问by Haseeb Warraich

Possible Duplicate:
How to print a portion of an HTML page?

可能的重复:
如何打印 HTML 页面的一部分?

I am making a quotation online. I want the user to be able to print it.

我在网上报价。我希望用户能够打印它。

I have seen my exact requirement on this webpage. On this web page, there is a print option. When the user clicks on print it will send a print command to the printer if a printer is attached.

我在这个网页上看到了我的确切要求。在此网页上,有一个打印选项。当用户单击打印时,如果连接了打印机,它将向打印机发送打印命令。

Does anyone know how can I do that?

有谁知道我该怎么做?

回答by Explosion Pills

<button id="printbutton" onclick="window.print();" />

回答by Blender

I'm quite confused by your question...

我对你的问题很困惑...

To trigger a print programatically with JavaScript (PHP won't help you much), you can call window.print():

要使用 JavaScript 以编程方式触发打印(PHP 不会帮助您太多),您可以调用window.print()

<input type="button" onclick="window.print()" />