網上看見的一個方法,保留下來以供以後再看
A頁面:
<iframe id="print" name="print" width = "0" height = "0" style = "display:"> </iframe>
<script>
function fd1(){
document.getElementById('print').src = "B.html ";
}
B頁面:
<script type="text/javascript">
function doPrint(){
window.focus(); //這個一定要有,否則打印的是A頁面+B頁面
window.print();
}
</script>
<body onload="javascript:doPrint()">
</body>