第一种方法:指定不打印区域
使用CSS,定义一个.noprint的class,将不打印的内容放入这个class内。
详细如下:
<style media=print type="text/css">
.noprint{visibility:hidden}
</style>
要打印的内容。
<p class="noprint">将不打印的代码放在这里。</p>
<a href="javascript:window.print()"
target="_self">打印</a>
第二种方法:指定打印区域
把要打印的内容放入一个 span或div,然后通过一个函数打印。
<span id='div1'>把要打印的内容放这里</span>
<p>所有内容</p>
<div id="div2">div2的内容</div>
<a href="javascript:printme()"
target="_self">打印</a>
<script>
function
printme()
{
document.body.innerHTML=document.getElementById('div1').innerHTML;
window.print();
}
</script>
如果要打印的只是整个页面中的一小部分,就最好采用第二种方法。
第三种方法:如果要打印的页面排版和原web页面相差很大,采用此种方法。
分享到:
相关推荐
How to use the Bayes Net Toolbox? This documentation was last updated on 29 October 2007.
The AI Advantage How to Put the Artificial Intelligence Revolution to Work
How to Answer The 64 Toughest Interview Question.pdf
The information in Web Content Management will give you a foundation of understanding necessary to make better decisions about platforms, features, architectures, and implementation methods to ensure...
通用打印类Generic printing class (and how to print a list control content) - Iuri Apollonio
How to Build a Web Dynpro Application
How to create branch and how to do the integration between the different branch in p4
Syngress - Stealing the Network - How to Own the Box (2003).pdf
Learn how to program JavaScript while creating interactive audio applications with JavaScript for Sound Artists: Learn to Code With the Web Audio API! William Turner and Steve Leonard showcase the ...
对研究生很有用的,叫你怎麽写英语论文 How to write and publish a scientific paper ContentsChapter 1 What Is Scientific Writing? Chapter 2 Origins of ...Chapter 11 How to State the Acknowledgments
Web Hacking 101: How to Make Money Hacking Ethically By 作者: Peter Yaworski Pub Date: 2018 ISBN: n/a Pages: 255 Language: English Format: PDF Size: 10 Mb With a Foreword written by HackerOne Co-...
How to Ace the Brainteaser Interview
i write a document for how to config the Python 3.0 environment. it can help the Python newer
How To Connect To The FTP Server
How to Use the Dictionary-(怎样使用词典-),How to Use the D-作文.pdf
Polya is one of the most frequently quoted mathematicians, and the following statements from "How to Solve It" make clear why: "My method to overcome a difficulty is to go around it." "Geometry is ...
paths and layers Build web files Master the basics of Photoshop with the visual examples and easy-to-follow lessons in How to Use Photoshop CS 2. <br> ...
如何打印编辑框中的内容How to print contents of an edit box