If you need to print the current page directly, then you don't have to look down, just use "print" in the toolbar that comes with your browser. If your actual need is to display a lot of content on the page, but you just want to print the contents of the specified area, and further may want to put together the content that was originally displayed, divided into several pages to print, then this article hopes to provide a minimalist solution.
The implementation of the method is very simple, the direct use of JavaScript with the Window.print () method to achieve similar click-to-browser printing effect, but this way is to print the contents of the current window (that is, the entire contents of the body). What if you want to print only the contents of the specified area? The simplest idea is to replace the contents of the body with the contents of the specified area before the content can be restored. What if the specified area is in one page of content and needs to be hard-broken into several pages for printing? With the help of the print properties in the CSS below, the content is divided into customized multipage pages according to the page style when printing.
The following code is directly affixed:
<!
DOCTYPE html>
Here in order to concise, quoted jquery plug-ins, the actual only with the original JS completely can be done, the idea is consistent on the line. If you need to split a lot of pages, then pull out the CSS paging style and write it in the style sheet and then reference it. In addition, This example only supports printing under Chrome.