HTML 打印预览问题,怎么设置有些内容不出现在打印预览页面上。怎么控制,有下代码 看得不是很懂 求解释

HTML 打印预览问题,怎么设置有些内容不出现在打印预览页面上。怎么控制,有下代码 看得不是很懂 求解释,第1张

核心部分就这些(起作用的?):

<!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/htmlcharset=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>

<HTML><HEAD><TITLE>打印-页面设置-打印预览-关闭窗口</TITLE>

<SCRIPT language=javascript>

function printsetup()

{

// 打印页面设置

wb.execwb(8,1)

}

function printpreview()

{

var ht1 = document.getElementByIdx_x("h")

ht1.style.display="none"//隐藏不必打印的部分,该隐藏只在预览中有效,真正打印时要用css控制

wb.execwb(7,1)// 打印页面预览

ht1.style.display="" //预览完再将隐藏的部分显示出来

}

function printit()

{

 if (confirm('确定打印吗?'))

{

wb.execwb(6,6)

}

}

</script>

<style type="text/css" media=print>

.noprint{display : none } //不打印

</style>

</HEAD>

<BODY>

<!-- div h 中的内容不打印 -->

<DIV id="h" align=center class="noprint">

<OBJECT id=wb height=0 width=0 classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2></OBJECT>

<INPUT onclick=javascript:printit() type=button value=打印 />

<INPUT onclick=javascript:printsetup()type=button value=打印页面设置 />

<INPUT onclick=javascript:printpreview()type=button value=打印预览 />

<INPUT onclick=javascript:window.close()type=button value=关闭 />

</DIV>

要打印的正文

</BODY>

</HTML>


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6108191.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-15
下一篇 2023-03-15

发表评论

登录后才能评论

评论列表(0条)

保存