我看网上有一个onafterprint 函数,是当文档被打印后触发的事件,可是我调用后也没达到预期功能,打印前就调用了这个函数,这个函数大家有用过的吗?(onafterprint )
实验代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<style media=print>
.Noprint{display:none;}
.PageNext{page-break-after: always;}
</style>
</HEAD>
<script language="javascript">
window.onafterprint=p_after
//window.onbeforeprint=p_befor
function p_after(){
alert('已经打印成功!!!');
window.close();
}
</script>
<BODY>
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0 VIEWASTEXT ></OBJECT>
<a class="NOPRINT" href="#" style="cursor:hand" title="打印" onclick="document.all.WebBrowser.ExecWB(6,6);">打印表一</a>
<br><br>
<table BORDER="1">
<tr><td>1</td></tr>
<tr><td>我将被打印</td></tr>
</table>
<br>
</BODY>
</HTML>