Home  >  Article  >  Web Front-end  >  Javascript打印网页部分内容的脚本_javascript技巧

Javascript打印网页部分内容的脚本_javascript技巧

WBOY
WBOYOriginal
2016-05-16 18:58:461276browse

正常情况下的打印是使用 window.print(); 直接整页打印,但如果需要打印网页中定义的部分内容,则可使用如下的方法:
1、在页面的代码头部处加入JavaScript:
JavaScript代码

复制代码 代码如下:



2、在页面正文处加上标识。
也就是在需要用户打印保存的正文所对应的html处附加上。同时,如果采用小偷程序获得远程数据并需打印,可将此等数据置于该定义标签之内即可。
3、截取内容部分已完成,现在加个“打印”的链接:
打印
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