HTML 打印预览问题,怎么设置有些内容不出现在打印预览页面上。怎么控制,有下代码 看得不是很懂 求解释 5
<html><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><head></head><...
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head></head>
<style type="text/css" media="screen">
@media print{
.print {display:block;}
.notPrint {display:none;}
}
</style>
<script language="javascript">
function preview()
{
bdhtml=window.document.body.innerHTML;
sprnstr="<!--startprint-->";
eprnstr="<!--endprint-->";
prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
window.document.body.innerHTML=prnhtml;
window.print();
}
</script>
<body>
<form id="WebForm1" method="post" > <div>1234567890</div>
<center>本部分以上不被打印</center>
<!--startprint-->
<div align="center">
<table border="1">
<tr bordercolor="#FFFFFF";>
<th bordercolor="#FFFFFF">销售单</th>
<th>工资单</th>
</tr>
<tr>
<td>销售单</td>
<td>销售123</td>
</tr>
</table>
</div>
<!--endprint-->
<center>本部分以下不被打印</center>
<div align="center">
<input type="button" name="print" value="预览并打印" onClick="preview()">
</div>
<style> @media Print { .Noprn { DISPLAY: none }}
</style>
<p class="Noprn">不打印</p>
<table id="datagrid">
<tr>
<td>打印</td>
</tr>
</table>
<input class="Noprn" type="button" onClick="window.print()" value="print">
</form> 展开
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head></head>
<style type="text/css" media="screen">
@media print{
.print {display:block;}
.notPrint {display:none;}
}
</style>
<script language="javascript">
function preview()
{
bdhtml=window.document.body.innerHTML;
sprnstr="<!--startprint-->";
eprnstr="<!--endprint-->";
prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
window.document.body.innerHTML=prnhtml;
window.print();
}
</script>
<body>
<form id="WebForm1" method="post" > <div>1234567890</div>
<center>本部分以上不被打印</center>
<!--startprint-->
<div align="center">
<table border="1">
<tr bordercolor="#FFFFFF";>
<th bordercolor="#FFFFFF">销售单</th>
<th>工资单</th>
</tr>
<tr>
<td>销售单</td>
<td>销售123</td>
</tr>
</table>
</div>
<!--endprint-->
<center>本部分以下不被打印</center>
<div align="center">
<input type="button" name="print" value="预览并打印" onClick="preview()">
</div>
<style> @media Print { .Noprn { DISPLAY: none }}
</style>
<p class="Noprn">不打印</p>
<table id="datagrid">
<tr>
<td>打印</td>
</tr>
</table>
<input class="Noprn" type="button" onClick="window.print()" value="print">
</form> 展开
展开全部
核心部分就这些(起作用的?):
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
function preview(){
bdhtml = window.document.body.innerHTML;
sprnstr = "<!--startprint-->";
eprnstr = "<!--endprint-->";
prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
prnhtml = prnhtml.substring(0,prnhtml.indexOf(eprnstr));
window.document.body.innerHTML = prnhtml;
window.print();
}
</script>
</head>
<body>
<form id="WebForm1" method="post" > <div>1234567890</div>
<center>本部分以上不被打印</center>
<!--startprint-->
<div align="center">
<table border="1">
<tr bordercolor="#FFFFFF";>
<th bordercolor="#FFFFFF">销售单</th>
<th>工资单</th>
</tr>
<tr>
<td>销售单</td>
<td>销售123</td>
</tr>
</table>
</div>
<!--endprint-->
<center>本部分以下不被打印</center>
<div align="center">
<input type="button" name="print" value="预览并打印" onClick="preview()">
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
function preview(){
bdhtml = window.document.body.innerHTML;
sprnstr = "<!--startprint-->";
eprnstr = "<!--endprint-->";
prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
prnhtml = prnhtml.substring(0,prnhtml.indexOf(eprnstr));
window.document.body.innerHTML = prnhtml;
window.print();
}
</script>
</head>
<body>
<form id="WebForm1" method="post" > <div>1234567890</div>
<center>本部分以上不被打印</center>
<!--startprint-->
<div align="center">
<table border="1">
<tr bordercolor="#FFFFFF";>
<th bordercolor="#FFFFFF">销售单</th>
<th>工资单</th>
</tr>
<tr>
<td>销售单</td>
<td>销售123</td>
</tr>
</table>
</div>
<!--endprint-->
<center>本部分以下不被打印</center>
<div align="center">
<input type="button" name="print" value="预览并打印" onClick="preview()">
</div>
</form>
</body>
</html>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
css 样式设置
将id为something 的元素 在打印时隐藏
@media print {
#something{
display:none;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
看到 css 里 media="screen" 没。media 就是 这个作用的!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询