如何打印特定部分。 [英] How to take printout of a particular portion.

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

问题描述





我正在创建一个表单。我想只打印表格。

当我使用

 window.print()



需要整页打印。



i想要有任何代码,以便我只能选择表格的选定部分。



谢谢

解决方案

试试这个



 < HTML> 
< head>

< script type =text / javascript>

函数CallPrint()
{

//从前一窗口获取内容
// var prtContent = document.getElementById(strid);
//这里你打开一个自定义大小的新窗口
var WinPrint = window.open(''''''''',

''左= 30 ,顶部= 0,宽度= 600,高度= 600,工具栏= 1,滚动条= 1,状态= 0 '');
var ss =''< table style =text-align:justify;>< tr>< td>< style type =text / css> your styles< / style> < h1> ITS A TEST ......< / h1>< br />< h1> ITS A TEST< / h1>< br />< br />< h1> ;打印内容.........< / h1>< br />< / td>< table>< tbody>< tr>< / tr>< / tbody> ;< /表>< / TR>< /表> '';
//准备页面内容
WinPrint.document.write(ss);
//将该内容写入新窗口
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
}

< / script>

< / head>

< body>

< br />
< br />
< br />

<aönclick=CallPrint()> PRINT< / a>

< / body>

< / html>


您好,

添加HTML页面

 <   head  >  
< script 语言 = javascript type = < span class =code-keyword> text / javascript src = print_part_page.js > < / script >
< / script > < / head >
< body >
< p id = printout style < span class =code-keyword> = font-size:150% > 将打印此部分页面! < / p <温泉n class =code-keyword>>
< p style = font-size:150% > < a href = onclick = var obj = new printPartOfPage(); obj.printPart('printout'); > 点击打印页面的一部分< / a > < / p >

< / body >





这里是print_part_page.js

  var  wi =  null ; 
printPartOfPage = function (){

< span class =code-keyword> if (wi&&(!wi.closed))
{
wi.close();
}

.printPart = function (divId)
{

html = document .getElementById(' ' + divId + ' ')。innerHTML;

wi = window .open(' '' printingpage');

wi。 document .write('


hi,

I am creating a form. and i want to take printout of the the form only.
When i use

window.print()


it take whole page for print.

i want is there any code so that i can take only the selected portion of the form.

thanks

解决方案

Try this

<html>
<head>

<script type="text/javascript">

function CallPrint()
   {
    
    // getting content from previous window
    //var prtContent = document.getElementById( strid );
    // here your are opening a new window with custom size
    var WinPrint = window.open('''', '''', 

''left=30,top=0,width=600,height=600,toolbar=1,scrollbars=1,status=0'');
    var ss=''<table style="text-align:justify;"><tr><td><style type="text/css">your styles</style><h1>ITS A TEST......</h1><br /><h1>ITS A TEST</h1><br /><br /><h1>CONTENT FOR PRINTING.........</h1><br /></td><table><tbody><tr></tr></tbody></table></tr></table>'';
    // preparing page content 
    WinPrint.document.write(ss);
    // writing that content to new window
    WinPrint.document.close();
    WinPrint.focus();
    WinPrint.print();
   }

</script>

</head>

<body>

<br />
<br />
<br />

<a  önclick="CallPrint()">PRINT</a>

</body>

</html>


Hi,
Add a html page

<head>
<script language="javascript" type="text/javascript" src="print_part_page.js"></script>
</script></head>
<body>
<p id="printout" style="font-size:150%">This part of page will be printed!</p>
<p style="font-size:150%"><a href="#" onclick="var obj = new printPartOfPage(); obj.printPart('printout');">Click to print a part of page</a></p>

</body>



here is the print_part_page.js

var wi = null;
printPartOfPage = function(){
				
					if( wi && (!wi.closed ) )
					  {
						  wi.close();
					  }
					  
					this.printPart = function(divId)
									{
						  
										html = document.getElementById(''+divId+'').innerHTML;
										
										wi=window.open('','printingpage');
										
										wi.document.write('


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

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