打印从网页中选择的数据

Lea*_*ner 0 html javascript css

我想打印选定的数据div而不是整页,我正在使用window.print()但它打印整个网页.

Suj*_*eet 6

如下例所示:

   <html>
    <head>
    <style type="text/css" media="print">
    @media print
    {
    #non-printable { display: none; }
    #printable {
    display: block;
    width: 100%;
    height: 100%;
    }
    }
    </style>
    </head>
    <body>
    <div id="printable" >
    Your content to print
    </div>
    <div id='non-printable'>
    this is not printable section
    </div>
    <input type="button" id="non-printable" class=normaltext onclick="JavaScript:window.print();" value="print" />
    </body>
    </html>
Run Code Online (Sandbox Code Playgroud)

有关更多详细信息或下载访问该网站:

http://blog.developeronhire.com/print-selected-div-in-web-page/