Home >Web Front-end >JS Tutorial >Three methods of page printing using JavaScript_Typical special effects

Three methods of page printing using JavaScript_Typical special effects

WBOY
WBOYOriginal
2016-05-16 19:18:152569browse

Some time ago, I heard a friend talk about some methods of printing web pages. On a quiet night, I accidentally discovered a few pieces of code while listening to music, and I posted them to share with you.

Because I have never printed a webpage, and I don’t have a printer, the specific effect is not very clear. It is normal to test printing to PDF, but the second one in the pop-up setting window is better than the first and third ones. There are more methods.

Note: The control in the second method requires the support of IE5.5, and because of the use of the control, if the security setting of the client IE is too high, it will not function properly.
Special Tips
Run this example code. If a printer has been installed, the printer will be directly called to print the page. Otherwise, you will be prompted to install a printer.

1. Use the print method of the window object



2. Use the WebBrowser control


classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">


3. Execute the print command in the document area


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn