我需要一个能使用Epson LQ-630k打印物流单的JS代码,要求是取消form下第一个DIV中的背景图片,只需要打印TEXTbox的内容,具体页面如下。
<!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 href="../css/ananaser.css" rel="stylesheet" type="text/css" />
<link href="../css/express.css" rel="stylesheet" type="text/css" />
<link href="../js/print.js" rel="stylesheet" type="text/css" />
</head>
<body>
<form name="form1" method="post" action="Express.aspx" id="form1">
<div class="express_big">
<table class="express_tab" border="0" cellspacing="0" cellpadding="0">
<tr><td width="310" valign="top">
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="65" valign="bottom">
<input name="TextBox1" type="text" id="TextBox1" class="Kong01" /><input name="TextBox2" type="text" id="TextBox2" class="Kong02" />
<input name="TextBox3" type="text" id="TextBox3" class="Kong03" /></td>
</tr>
<tr>
<td height="42" align="left" valign="bottom"><input name="TextBox4" type="text" id="TextBox4" style="width:293px;" /></td>
</tr>
<tr>
<td height="41" align="left" valign="bottom"><input name="TextBox5" type="text" id="TextBox5" class="Kong04" /></td>
</tr>
<tr>
<td height="50"><input name="TextBox6" type="text" id="TextBox6" class="Kong05" /><input name="TextBox7" type="text" id="TextBox7" class="Kong06" /></td>
</tr>
<tr>
<td height="50"></td>
</tr>
<tr>
<td height="58" valign="bottom"><input name="TextBox8" type="text" id="TextBox8" class="Kong07" /><input name="TextBox9" type="text" id="TextBox9" class="Kong08" />
<input name="TextBox10" type="text" id="TextBox10" class="Kong09" /><input name="TextBox11" type="text" id="TextBox11" class="Kong09" /> <input name="TextBox12" type="text" id="TextBox12" class="Kong09" /></td>
</tr>
<tr>
<td height="27" align="right" valign="bottom" ><input name="TextBox13" type="text" id="TextBox13" class="Kong10" /></td>
</tr>
</table></td>
<td width="320" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="12" rowspan="9" valign="bottom"> </td>
<td height="64" valign="bottom"><input name="TextBox14" type="text" id="TextBox14" class="Kong01" /><input name="TextBox15" type="text" id="TextBox15" class="Kong02" /><input name="TextBox16" type="text" id="TextBox16" class="Kong03" /></td>
</tr>
<tr>
<td height="42" align="left" valign="bottom"><input name="TextBox17" type="text" id="TextBox17" style="width:294px;" /></td>
</tr>
<tr>
<td height="41" align="left" valign="bottom"><input name="TextBox18" type="text" id="TextBox18" class="Kong04" /></td>
</tr>
<tr>
<td height="50"><input name="TextBox19" type="text" id="TextBox19" class="Kong05" /><input name="TextBox20" type="text" id="TextBox20" class="Kong06" /></td>
</tr>
<tr>
<td height="33" align="left"> <input name="01" type="text" class="Kong11" size="17" />
<input name="015" type="text" class="Kong12" size="8" /></td></tr>
<tr>
<td height="33" valign="bottom"><input name="014" type="text"/ class="Kong13"> <input name="02" type="text" class="wid"/> <input name="02" type="text" class="wid"/> <input name="02" type="text" class="wid"/> <input name="02" type="text" class="wid"/></td></tr>
<tr>
<td height="25"> </td></tr>
<tr>
<td height="25" valign="bottom" > <input name="012" type="text" class="Kong07"/><input name="012" type="text" class="Kong08" />
<input name="012" type="text" class="Kong09" /> <input name="012" type="text" class="Kong09" /> <input name="012" type="text" class="Kong09"/></td>
</tr>
<tr>
<td height="18" valign="top"> <input name="01" type="text" class="Kong04"/></td>
</tr>
</table></td>
<td valign="top" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="70" rowspan="8"> </td>
<td height="3"> </td>
<td height="30"><input name="01222" type="text" size="8"/></td>
</tr>
<tr>
<td height="75" valign="top"> </td>
</tr>
<tr>
<td height="30" valign="bottom"><label>
</label></td>
</tr>
<tr>
<td height="35" valign="middle"> <input name="012222" type="text" size="7"/></td>
</tr>
<tr>
<td height="55" valign="bottom" > <input name="012222" type="text" size="7"/></td>
</tr>
<tr>
<td height="33" valign="bottom" > <input name="012222" type="text" size="7"/></td>
</tr>
<tr>
<td height="26" valign="bottom"> <input name="012222" type="text" size="7"/></td>
</tr>
<tr>
<td height="50" > </td>
</tr>
</table>
</td> </tr></table>
</div>
</form>
</body>
</html>
<!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 href="../css/ananaser.css" rel="stylesheet" type="text/css" />
<link href="../css/express.css" rel="stylesheet" type="text/css" />
<link href="../js/print.js" rel="stylesheet" type="text/css" />
</head>
<body>
<form name="form1" method="post" action="Express.aspx" id="form1">
<div class="express_big">
<table class="express_tab" border="0" cellspacing="0" cellpadding="0">
<tr><td width="310" valign="top">
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="65" valign="bottom">
<input name="TextBox1" type="text" id="TextBox1" class="Kong01" /><input name="TextBox2" type="text" id="TextBox2" class="Kong02" />
<input name="TextBox3" type="text" id="TextBox3" class="Kong03" /></td>
</tr>
<tr>
<td height="42" align="left" valign="bottom"><input name="TextBox4" type="text" id="TextBox4" style="width:293px;" /></td>
</tr>
<tr>
<td height="41" align="left" valign="bottom"><input name="TextBox5" type="text" id="TextBox5" class="Kong04" /></td>
</tr>
<tr>
<td height="50"><input name="TextBox6" type="text" id="TextBox6" class="Kong05" /><input name="TextBox7" type="text" id="TextBox7" class="Kong06" /></td>
</tr>
<tr>
<td height="50"></td>
</tr>
<tr>
<td height="58" valign="bottom"><input name="TextBox8" type="text" id="TextBox8" class="Kong07" /><input name="TextBox9" type="text" id="TextBox9" class="Kong08" />
<input name="TextBox10" type="text" id="TextBox10" class="Kong09" /><input name="TextBox11" type="text" id="TextBox11" class="Kong09" /> <input name="TextBox12" type="text" id="TextBox12" class="Kong09" /></td>
</tr>
<tr>
<td height="27" align="right" valign="bottom" ><input name="TextBox13" type="text" id="TextBox13" class="Kong10" /></td>
</tr>
</table></td>
<td width="320" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="12" rowspan="9" valign="bottom"> </td>
<td height="64" valign="bottom"><input name="TextBox14" type="text" id="TextBox14" class="Kong01" /><input name="TextBox15" type="text" id="TextBox15" class="Kong02" /><input name="TextBox16" type="text" id="TextBox16" class="Kong03" /></td>
</tr>
<tr>
<td height="42" align="left" valign="bottom"><input name="TextBox17" type="text" id="TextBox17" style="width:294px;" /></td>
</tr>
<tr>
<td height="41" align="left" valign="bottom"><input name="TextBox18" type="text" id="TextBox18" class="Kong04" /></td>
</tr>
<tr>
<td height="50"><input name="TextBox19" type="text" id="TextBox19" class="Kong05" /><input name="TextBox20" type="text" id="TextBox20" class="Kong06" /></td>
</tr>
<tr>
<td height="33" align="left"> <input name="01" type="text" class="Kong11" size="17" />
<input name="015" type="text" class="Kong12" size="8" /></td></tr>
<tr>
<td height="33" valign="bottom"><input name="014" type="text"/ class="Kong13"> <input name="02" type="text" class="wid"/> <input name="02" type="text" class="wid"/> <input name="02" type="text" class="wid"/> <input name="02" type="text" class="wid"/></td></tr>
<tr>
<td height="25"> </td></tr>
<tr>
<td height="25" valign="bottom" > <input name="012" type="text" class="Kong07"/><input name="012" type="text" class="Kong08" />
<input name="012" type="text" class="Kong09" /> <input name="012" type="text" class="Kong09" /> <input name="012" type="text" class="Kong09"/></td>
</tr>
<tr>
<td height="18" valign="top"> <input name="01" type="text" class="Kong04"/></td>
</tr>
</table></td>
<td valign="top" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="70" rowspan="8"> </td>
<td height="3"> </td>
<td height="30"><input name="01222" type="text" size="8"/></td>
</tr>
<tr>
<td height="75" valign="top"> </td>
</tr>
<tr>
<td height="30" valign="bottom"><label>
</label></td>
</tr>
<tr>
<td height="35" valign="middle"> <input name="012222" type="text" size="7"/></td>
</tr>
<tr>
<td height="55" valign="bottom" > <input name="012222" type="text" size="7"/></td>
</tr>
<tr>
<td height="33" valign="bottom" > <input name="012222" type="text" size="7"/></td>
</tr>
<tr>
<td height="26" valign="bottom"> <input name="012222" type="text" size="7"/></td>
</tr>
<tr>
<td height="50" > </td>
</tr>
</table>
</td> </tr></table>
</div>
</form>
</body>
</html>
或定义style:
@media print {
.notprint {
display:none;
}
}@media screen {
.notprint {
display:inline;
cursor:hand;
}
}所有需要显示但不需要打印(预览)的元素都加上: class='notprint'打印部分
function PreviewPrint()
{
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;
var obj=document.getElementById("");
if (obj!=null)
{
var rows = obj.rows;
var hide=rows.length-1;
obj.rows(hide).style.display = "none";
}
window.print();
window.parent.returnValue='0';
}