如何打印我的网页. [英] How to print of my web page.

查看:68
本文介绍了如何打印我的网页.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想打印我的网页.
但它具有1个gridview,1个Treeview,3个Button,3个图像,页眉和页脚控件.
我想删除所有上述控件.我只想保留我的打印内容.
&主要是它具有母版页内容.
因此,如何删除网页中的所有控件以及如何打印网页.

在此先感谢,
VenkiDesai.

Hi All,

I want to give print of my web page.
But it has 1 gridview,1 Treeview, 3 Button ,3 Images,Header & Footer Controls.
I want to remove all the above mentioned controls.I want remain my print content only.
& the main thing is that it has master page content.
So how to remove all the controls in my web page & how to give the print of the web page.

Thanks in Advance,
VenkiDesai.

推荐答案

创建一个"print.css"样式表,该样式表将隐藏所有不想打印的元素.并使用media ="print"
添加它
Create a "print.css" stylesheet which hides all the elements you don''t want to print. And add it with a media="print"
<link rel="stylesheet" type="text/css" href="print.css" media="print" />
</link>



在该文件(print.css)中,隐藏了所有不想打印的元素.



In that file (print.css) you hide all elements that you don''t want to print.

#header {display:none;}
#footer {display:none;}

/* hide my treeview */
.treeview {display:none;}

/* hide my grids */
.grid {display:none;}
/* Hide all buttons, dropdowns etc. */
input, select, textarea {display:none;}



当然,您将必须为网格,树视图等设置一些类.或者您可以向所有不应打印的元素添加"noprint"类.在这种情况下,您可以将其添加到print.css



You will of course have to set some classes to your grid''s, treeview''s etc. Or you can just add a "noprint" class to all elements which should not be printed. In that case you can just add this to your print.css

.noprint {display:none;}


您的css文件应包含两部分
your css file should has 2 parts
@media screen
{
    .button
    {
        
    }
}
@media print
{
    .button
    {
         display: none;
    }
}


为此,尊敬的朋友,您应该使用JavaScript

Dear Friend for this you Should use JavaScript

<script type="text/javascript" language="javascript">
function getPrint(print_area) {

    var disp_setting = "toolbar=false,location=no,directories=yes,menubar=false,";
    disp_setting += "scrollbars=yes,width=880, height=600, left=100, top=25";
    var content_vlue = document.getElementById("print_area").innerHTML;
    var str = "UGANDA EMIS II PROJECT ICT INFRASTRUCTURE NEEDS ASSESSMENT IN EDUCATION & SPORTS SECTOR";
    var docprint = window.open("", "", disp_setting);
    docprint.document.writeln(str.bold());
    docprint.document.writeln('<base target="_self">')
    //Adding Body Tag
    docprint.document.writeln('<body ms_positioning="GridLayout" bottommargin="0" leftmargin="0" topmargin="0" rightmargin="0">');
    //Adding form Tag
    docprint.document.writeln('<form method="post">');
    //Creating two buttons Print and Close within a table

    docprint.document.writeln('<input id="PRINT" type="button" value="Print"  önclick="javascript:location.reload(false);window.print();"><input id="CLOSE" type="button" value="Close"  önclick="window.close();">');
    //Writing print area of the calling page
    docprint.document.writeln(document.getElementById(print_area).innerHTML);
    //Ending Tag of </input></input></form>, </body> and 
    docprint.document.writeln('');
}
</base></script>


并在按钮事件中
u应该调用打印功能.


and in BUTTON EVENT
u SHOULD CALL THE Print Function.


这篇关于如何打印我的网页.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆