公司里面要打印功很急 . 大家帮帮忙啊
我不知道web打印 哪种方式好点? 希望大家给点建议 或者给我份例子 发到[email protected] 我在网上查了下资料 用IE自带的功能打印的 我的用的浏览器是IE8
全部都是用js写 打印预览没问题 主要就是浏览器有拦截问题 我要改IE里面设置才可以
下面是我写一部分的测试代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" media="print" type="text/css" href="bankprint.css" /><script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
function myclose(){
window.close();
}
var hkey_root,hkey_path,hkey_key;
hkey_root="HKEY_CURRENT_USER";
hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
//配置网页打印的页眉页脚为空
function pagesetup_null(){
try{
var RegWsh = new ActiveXObject("WScript.Shell");
hkey_key="header";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
hkey_key="footer";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
//&b 第&p页/共&P页 &b
}catch(e){}
}
//配置网页打印的页眉页脚为默认值
function pagesetup_default(){
try{
var RegWsh = new ActiveXObject("WScript.Shell");
hkey_key="header";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P")
hkey_key="footer";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d");
}catch(e){}
}
//打印选区内容
function doPrint() {
pagesetup_null();
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();
}
//打印页面预览
function printpreview(){
pagesetup_null();
//wb.printing.header = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页";
//wb.printing.footer = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页";
try{
wb.execwb(7,1);
}catch(e){
alert("您的浏览器不支持此功能,请选择'文件'->'打印预览'");
}
}
//打印
function prints(){
pagesetup_null();
//wb.printing.header = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页";
//wb.printing.footer = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页";
try{
wb.execwb(6,1);
}catch(e){
alert("您的浏览器不支持此功能");
}
}
</script>
</head><body>
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" id="wb" width="0" height="0"></OBJECT>
<div id="bankwrap" align="center">
<div class="Noprint" > 下面红色内容打印到厨房的</div>
<table width="500" border="1" cellpadding="0" cellspacing="0"> <tbody class="banktitle" bgcolor="#FF0000">
<tr height="10">
<th height="21" scope="col">菜名</th>
<th align="center" scope="col">数量 </th>
</tr>
<tr >
<th height="42" align="center" scope="col">He dried the dishes carefully</th>
<th class="dish" scope="col">22</th>
</tr>
</tbody>
<tr class="Noprint" >
<th height="42" align="center" scope="col">酒水的不要去厨房</th>
<th class="dish" scope="col">22</th>
</tr>
</table>
<div class="Noprint">
<table width="500" border="1" cellpadding="0" cellspacing="0">
<tr>
</th>
<th><button style=" width: 80px; height: 30px; font-size:24px" onclick="printpreview();" > 打印</button>
</th>
<th><button style=" width: 80px; height: 30px; font-size:24px" > 保存</button>
</th>
<th>
<button style=" width: 80px; height: 30px; font-size:24px" onclick="myclose();" > 退出</button>
</th>
</tr>
</table>
</div>
</div>
</body>
</html>
/* BankController 中国银行CSS 打印样式 */.Noprint {display:none;} /* 声明了该样式的元素将不会被打印 */
.PageBreak {page-break-after: always;} /* 分页标志,在需要分页的地方插入具有该样式的元素,将自动分页 */* {
margin:0;
padding:0;
}
body {
/*font-size:20px;
background-color: #FF0000;
*/
/* font-family: "lucida sans unicode",georgia;*/
font-size: 12pt;
color:#00FF99;
background-color: #FF0000;
background-image: none;}
ul {
list-style:none;
}/*---- 内容页面样式 ------*/
#bankwrap {
margin:0 auto;
/* width:595px; */
width:500px;
overflow:hidden;
padding:10px;
/*border:1px solid #c3c3c3;*/
/* background-color:#fff; */
background-color: red;
}
#bankpage {
width:595px;
/*height:842px;*/
/*border:1px solid #c3c3c3;*/
}
#footer {
/*
padding:8px 0px;
text-align:center;
background:url('../img/csvf/bgtag/core_bg.jpg') repeat-x;
*/
}
/* //打印内容范围 */
.bankcontent{
/*border:1px solid blue;*/
background-color: #FF0000;
}.banktitle{
font-size:16px;
font-weight:bold;
line-height:30px;
display:block;
text-align:center;
border-bottom:1px dashed #c3c3c3;
margin-bottom:20px;
}
.bankbtn {
padding:5px 0px;
text-align:center;
margin-bottom:20px;
border-bottom:1px dashed #c3c3c3;
}/* 公用样式 */
.hrdash {
height:1px;
border:none;
border-bottom:1px dashed #c3c3c3;
}/* //内容块 */
.bankbox {
margin:4px 0px;
overflow:hidden;
}
.bankbox .boxtitle {
height:30px;
line-height:30px;
padding:0px 4px;
font-size:14px;
font-weight:bold;
background-color: #6C3;
/*background:url('../img/csvf/bgtag/center_bg.gif') repeat-x;*/
/*background:url('../img/csvf/bgtag/dtbg.gif') repeat-x;*/
}
.bankbox .boxcontent {
padding:4px 8px;
}
.bankbox p {
margin:1px 0px;
clear:both;
}
.bankbox input {
/*border-top:medium none;
border-color: #CCC;
border-width:1px;*/
margin-left:2px;
}
.bankbox .tabtitle {
vertical-align:top;
}.boxinput {
letter-spacing:2px;
}
.valitop{
vertical-align:top;
}
我不知道web打印 哪种方式好点? 希望大家给点建议 或者给我份例子 发到[email protected] 我在网上查了下资料 用IE自带的功能打印的 我的用的浏览器是IE8
全部都是用js写 打印预览没问题 主要就是浏览器有拦截问题 我要改IE里面设置才可以
下面是我写一部分的测试代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" media="print" type="text/css" href="bankprint.css" /><script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
function myclose(){
window.close();
}
var hkey_root,hkey_path,hkey_key;
hkey_root="HKEY_CURRENT_USER";
hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
//配置网页打印的页眉页脚为空
function pagesetup_null(){
try{
var RegWsh = new ActiveXObject("WScript.Shell");
hkey_key="header";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
hkey_key="footer";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
//&b 第&p页/共&P页 &b
}catch(e){}
}
//配置网页打印的页眉页脚为默认值
function pagesetup_default(){
try{
var RegWsh = new ActiveXObject("WScript.Shell");
hkey_key="header";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P")
hkey_key="footer";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d");
}catch(e){}
}
//打印选区内容
function doPrint() {
pagesetup_null();
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();
}
//打印页面预览
function printpreview(){
pagesetup_null();
//wb.printing.header = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页";
//wb.printing.footer = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页";
try{
wb.execwb(7,1);
}catch(e){
alert("您的浏览器不支持此功能,请选择'文件'->'打印预览'");
}
}
//打印
function prints(){
pagesetup_null();
//wb.printing.header = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页";
//wb.printing.footer = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页";
try{
wb.execwb(6,1);
}catch(e){
alert("您的浏览器不支持此功能");
}
}
</script>
</head><body>
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" id="wb" width="0" height="0"></OBJECT>
<div id="bankwrap" align="center">
<div class="Noprint" > 下面红色内容打印到厨房的</div>
<table width="500" border="1" cellpadding="0" cellspacing="0"> <tbody class="banktitle" bgcolor="#FF0000">
<tr height="10">
<th height="21" scope="col">菜名</th>
<th align="center" scope="col">数量 </th>
</tr>
<tr >
<th height="42" align="center" scope="col">He dried the dishes carefully</th>
<th class="dish" scope="col">22</th>
</tr>
</tbody>
<tr class="Noprint" >
<th height="42" align="center" scope="col">酒水的不要去厨房</th>
<th class="dish" scope="col">22</th>
</tr>
</table>
<div class="Noprint">
<table width="500" border="1" cellpadding="0" cellspacing="0">
<tr>
</th>
<th><button style=" width: 80px; height: 30px; font-size:24px" onclick="printpreview();" > 打印</button>
</th>
<th><button style=" width: 80px; height: 30px; font-size:24px" > 保存</button>
</th>
<th>
<button style=" width: 80px; height: 30px; font-size:24px" onclick="myclose();" > 退出</button>
</th>
</tr>
</table>
</div>
</div>
</body>
</html>
/* BankController 中国银行CSS 打印样式 */.Noprint {display:none;} /* 声明了该样式的元素将不会被打印 */
.PageBreak {page-break-after: always;} /* 分页标志,在需要分页的地方插入具有该样式的元素,将自动分页 */* {
margin:0;
padding:0;
}
body {
/*font-size:20px;
background-color: #FF0000;
*/
/* font-family: "lucida sans unicode",georgia;*/
font-size: 12pt;
color:#00FF99;
background-color: #FF0000;
background-image: none;}
ul {
list-style:none;
}/*---- 内容页面样式 ------*/
#bankwrap {
margin:0 auto;
/* width:595px; */
width:500px;
overflow:hidden;
padding:10px;
/*border:1px solid #c3c3c3;*/
/* background-color:#fff; */
background-color: red;
}
#bankpage {
width:595px;
/*height:842px;*/
/*border:1px solid #c3c3c3;*/
}
#footer {
/*
padding:8px 0px;
text-align:center;
background:url('../img/csvf/bgtag/core_bg.jpg') repeat-x;
*/
}
/* //打印内容范围 */
.bankcontent{
/*border:1px solid blue;*/
background-color: #FF0000;
}.banktitle{
font-size:16px;
font-weight:bold;
line-height:30px;
display:block;
text-align:center;
border-bottom:1px dashed #c3c3c3;
margin-bottom:20px;
}
.bankbtn {
padding:5px 0px;
text-align:center;
margin-bottom:20px;
border-bottom:1px dashed #c3c3c3;
}/* 公用样式 */
.hrdash {
height:1px;
border:none;
border-bottom:1px dashed #c3c3c3;
}/* //内容块 */
.bankbox {
margin:4px 0px;
overflow:hidden;
}
.bankbox .boxtitle {
height:30px;
line-height:30px;
padding:0px 4px;
font-size:14px;
font-weight:bold;
background-color: #6C3;
/*background:url('../img/csvf/bgtag/center_bg.gif') repeat-x;*/
/*background:url('../img/csvf/bgtag/dtbg.gif') repeat-x;*/
}
.bankbox .boxcontent {
padding:4px 8px;
}
.bankbox p {
margin:1px 0px;
clear:both;
}
.bankbox input {
/*border-top:medium none;
border-color: #CCC;
border-width:1px;*/
margin-left:2px;
}
.bankbox .tabtitle {
vertical-align:top;
}.boxinput {
letter-spacing:2px;
}
.valitop{
vertical-align:top;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货