Javascript打印不会';t工作-不打印整页
我试图打印整页,但它不工作尝试不同的代码,但没有成功 下面是一段代码Javascript打印不会';t工作-不打印整页,javascript,html,printing,Javascript,Html,Printing,我试图打印整页,但它不工作尝试不同的代码,但没有成功 下面是一段代码 <html> <head> <SCRIPT LANGUAGE="JavaScript"> if (window.print) { document.write('<form><input type=button name=print value="Print" onClick="window.print()"></form>'); } </
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
if (window.print) {
document.write('<form><input type=button name=print value="Print" onClick="window.print()"></form>');
}
</script>
<style type="text/css" media="all">
body{font-size:1em;}
table{font-size:0.9em;}
.price{text-align:right;padding-right:5px;}
.center{text-align:center;}
table tr{height:20px;}
@media print {body, html{width: 100%;}}
#top, #bottom {display: none;}
</style>
</head>
<body style="width:100%;">
<table width="94%" style="margin-left:2%;">
<tr>
<td width="100%" colspan="3" class="center" style="height:35px;"> <span style="text-transform:uppercase;"><b>ORDER TYPE </b></span></td>
</tr>
<tr></table>
</body></html>
如果(窗口打印){
文件。写(“”);
}
正文{字体大小:1em;}
表{字体大小:0.9em;}
.price{text align:right;padding right:5px;}
.center{text align:center;}
表tr{高度:20px;}
@媒体打印{正文,html{宽度:100%;}
#顶部,#底部{显示:无;}
订单类型
请帮帮我
谢谢您是否试图通过javascript呈现页面?如果是,以下教程可能会有所帮助 建议阅读本教程的以下API
document.getElementById(id).innerHTML=新HTML
希望这对您有所帮助。这应该适合您:
<html>
<head>
<style type="text/css" media="all">
body{font-size:1em;}
table{font-size:0.9em;}
.price{text-align:right;padding-right:5px;}
.center{text-align:center;}
table tr{height:20px;}
@media print {body, html{width: 100%;}}
#top, #bottom {display: none;}
</style>
</head>
<body style="width:100%;">
<input type=button name=print value="Print" onClick="window.print()">
<table style="margin-left:2%;width:94%;">
<tr>
<td width="100%" colspan="3" class="center" style="height:35px;"> <span style="text-transform:uppercase;"><b>ORDER TYPE </b></span></td>
</tr>
<tr></table>
</body></html>
正文{字体大小:1em;}
表{字体大小:0.9em;}
.price{text align:right;padding right:5px;}
.center{text align:center;}
表tr{高度:20px;}
@媒体打印{正文,html{宽度:100%;}
#顶部,#底部{显示:无;}
订单类型
注意:始终正确构建html。宽度是样式标记的一部分,而不是标记本身。请参见此链接: