你的这段代码本来就是要弹出一个消息框。 这是以前用vbscript写的东西,你参考一下。<script language=vbscript> sub window_onbeforeprint() tbfy.style.display="none" end sub sub window_onafterprint() tbfy.style.display="inline" end sub sub mydy() on error resume next if form1.setpage.value="true" then myprint.execwb 6,6 else window.alert "请纵向插入A4纸张" myprint.execwb 6,6 form1.setpage.value="true" end if
var mStr;
mStr = window.document.body.innerHTML ;
var mWindow = window;
window.document.body.innerHTML =Id.innerHTML;
mWindow.print();
window.document.body.innerHTML = mStr;
}
</script>
<body>
There will be not printed!
<div ID="Table">
<table border="1" width="92%" height="24%">
<TR>
<TD>
print
</TD>
<TD>
print
</TD>
</TR>
</TABLE>
</DIV>
<input type="submit" value="submit" onclick="return PrintTable(Table)">试试先!祝好运!
为什么我的就只弹出一个消息框,写着"window.print()"?
这是以前用vbscript写的东西,你参考一下。<script language=vbscript>
sub window_onbeforeprint()
tbfy.style.display="none"
end sub sub window_onafterprint()
tbfy.style.display="inline"
end sub sub mydy()
on error resume next
if form1.setpage.value="true" then
myprint.execwb 6,6
else
window.alert "请纵向插入A4纸张"
myprint.execwb 6,6
form1.setpage.value="true"
end if
end sub
</script>
把你不想打印的东西放到id 为tbfy 代码里面。
例如:<table border="0" cellpadding="0" cellspacing="0" style="margin-left:0;BORDER-COLLAPSE: collapse" bordercolor="#111111" width="681" id="tbfy" height="28">
<tr>
<td width="679"><p align=center> <input type="button" value=" 打印 " name="B1" onclick="mydy()"> <input type="button" value=" 关闭 " name="B2" onclick="vbscript:window.close "> </p>
</td>
</tr>
</table>